AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Find the first number in a string??

 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
jmsssm



Joined: 19 Mar 2008
Posts: 6

PostPosted: Tue May 13, 2008 11:59 am    Post subject: Find the first number in a string?? Reply with quote

Hey,

I need help finding the first number (0 doesn't count) in a string of this type:

String : INC000000173753

So i need the pos of 1.

note what i really need is the number in the end , because string could also be like these:

String ex1. : INC173753
String ex2. : 00000173753
String ex3. : 173753
String ex4. : INC000123

My guess is that if i find the first number i can do the script!

anyone? doing these for long time and with no solution yet...


thnx in advance!
Back to top
View user's profile Send private message
Z Gecko
Guest





PostPosted: Tue May 13, 2008 12:06 pm    Post subject: Reply with quote

if you need the last number, get it directly.
Code:
StringRight, LastNr, String, 1 
Back to top
Oberon



Joined: 18 Feb 2008
Posts: 458

PostPosted: Tue May 13, 2008 12:07 pm    Post subject: Reply with quote

Use regex:

Code:
str = INC000000173753

pos := RegExMatch("x" . str, ".*\D0*(\d+)", num)
MsgBox, Position: %pos%`nNumber: %num1%
Back to top
View user's profile Send private message
aaffe



Joined: 17 May 2007
Posts: 66

PostPosted: Tue May 13, 2008 12:09 pm    Post subject: Reply with quote

try this:
Code:

A1=INC173753
A2=00000173753
A3=173753
A4=INC000123

Loop 4
{
  zeile:=A%A_Index%
  fund:=RegExMatch(zeile,"([1-9])",ausgabe)
  if fund>0
    msgbox %ausgabe%
}
Back to top
View user's profile Send private message
jmsssm



Joined: 19 Mar 2008
Posts: 6

PostPosted: Tue May 13, 2008 1:41 pm    Post subject: Reply with quote

Thanks Oberon!

It works...

script running ahahahahahah

thnx all
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group