On Sat, 2 Oct 2010 01:14:27 am Alex Hall wrote:
> >> Here is my test:
> >> s=re.search(r"[\d+\s+\d+\s+\d]", l)
> >
> > Try this instead:
> >
> > re.search(r'\d+\s+\D*\d+\s+\d', l)
[...]
> Understood. My intent was to ask why my regexp would match anything
> at all.

Square brackets create a character set, so your regex tests for a string 
that contains a single character matching a digit (\d), a plus sign (+) 
or a whitespace character (\s). The additional \d + \s in the square 
brackets are redundant and don't add anything.

-- 
Steven D'Aprano
_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to