| View previous topic :: View next topic |
| Author |
Message |
jmsssm
Joined: 19 Mar 2008 Posts: 6
|
Posted: Tue May 13, 2008 11:59 am Post subject: Find the first number in a string?? |
|
|
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 |
|
 |
Z Gecko Guest
|
Posted: Tue May 13, 2008 12:06 pm Post subject: |
|
|
if you need the last number, get it directly.
| Code: | | StringRight, LastNr, String, 1 |
|
|
| Back to top |
|
 |
Oberon
Joined: 18 Feb 2008 Posts: 458
|
Posted: Tue May 13, 2008 12:07 pm Post subject: |
|
|
Use regex:
| Code: | str = INC000000173753
pos := RegExMatch("x" . str, ".*\D0*(\d+)", num)
MsgBox, Position: %pos%`nNumber: %num1% |
|
|
| Back to top |
|
 |
aaffe
Joined: 17 May 2007 Posts: 66
|
Posted: Tue May 13, 2008 12:09 pm Post subject: |
|
|
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 |
|
 |
jmsssm
Joined: 19 Mar 2008 Posts: 6
|
Posted: Tue May 13, 2008 1:41 pm Post subject: |
|
|
Thanks Oberon!
It works...
script running ahahahahahah
thnx all |
|
| Back to top |
|
 |
|