[Tutor] regexp: a bit lost
mehgcap at gmail.com
Sat Oct 2 02:47:29 CEST 2010
On 10/1/10, Steven D'Aprano <steve at pearwood.info> wrote:
> 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.
Oh, that explains it then. :) Thanks.
> Steven D'Aprano
> Tutor maillist - Tutor at python.org
> To unsubscribe or change subscription options:
Have a great day,
Alex (msg sent from GMail website)
mehgcap at gmail.com; http://www.facebook.com/mehgcap
More information about the Tutor