parsing combination strings
PKKR
superprad at gmail.com
Wed Mar 21 14:42:29 EDT 2007
I need a fast and efficient way to parse a combination string(digits +
chars)
ex: s = "12ABA" or "1ACD" or "123CSD" etc
I want to parse the the above string such that i can grab only the
first digits and ignore the rest of the chacters,
so if i have s = "12ABA" , parser(s) should give me "12" or "1" or
"123".
I can think of a quick dirty way by checking each element in the
string and do a 'str.isdigit()' and stop once its not a digit, but
appreciate any eligent way.
More information about the Python-list
mailing list