Extract number out of undefined string chain
MMUCB
I d like to extract a number out of a string looking like
String Name = "Shot_Exp_System_s12345"
I want to get 12345, which will always be a 5 digit number
however the string in front of it may change, though it will most of the time have " _s" just before the number
any idea ?
I tried
String Name = "Shot_Exp_System_s12345"
Variable var
sscanf Name, "%*s[_s]%5d", var
Print var
it only sees the string and gives 0
String Name = "Shot_Exp_System_s12345"
String str
Variable var
sscanf Name, "%[^0-9]%d", str, var
Print str
Print var
End
January 30, 2012 at 07:41 pm - Permalink
January 31, 2012 at 09:23 am - Permalink