Bruno Desthuilliers:
> exp = re.compile(r'^([0-9]+)')
> for s in ["12ABA", "1ACD", "123CSD"]:
> print exp.match(line).group(0)
This may be enough too:
exp = re.compile(r'\d+')
for s in ["12ABA", "1ACD", "123CSD"]:
print exp.match(line).group(0)
With it:
exp.match("a123CSD") = None
Bye,
PKKR a écrit :
> On Mar 21, 2:51 pm, "Steven D. Arnold" <[EMAIL PROTECTED]> wrote:
>
>>On Mar 21, 2007, at 2:42 PM, PKKR wrote:
>>
>>
>>>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 ab
On Mar 21, 2:51 pm, "Steven D. Arnold" <[EMAIL PROTECTED]> wrote:
> On Mar 21, 2007, at 2:42 PM, PKKR wrote:
>
> > 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
ah ok, i guess something like this should do it for me then?
re.split('[^0-9]', str)[0]
--
http://mail.python.org/mailman/listinfo/python-list
On Mar 21, 1:42 pm, "PKKR" <[EMAIL PROTECTED]> wrote:
> 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 chac
On Mar 21, 2007, at 2:42 PM, PKKR wrote:
> 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,
A rege
On 21 mar 2007, at 19.42, PKKR wrote:
> 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 i
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