+ in regular expression

Evan Driscoll driscoll at cs.wisc.edu
Thu Oct 4 22:25:40 EDT 2012


On 10/04/2012 04:59 PM, Mark Lawrence wrote:
>> why the  "\s{6}+"  is not a regular pattern?
>>
>>
>>
>
>
> Why are you too lazy to do any research before posting a question?
>
Errr... what?

I'm only somewhat familiar with the extra stuff that languages provide 
in their regexs beyond true regular expressions and simple extensions, 
but I was surprised to see the question because I too would have 
expected that to work. (And match any sequence of whitespace characters 
whose length is a multiple of six.) I reskimmed the documentation of the 
re module and didn't see anything that would prohibit it. I looked at 
several of the results of a Google search for the multiple repeat error, 
and didn't really find any explanation beyond "because you can't do it" 
or "here's a regex that works." (Well, OK, I did see a mention of + 
being a possessive quantifier which Python doesn't support. But that 
still doesn't explain why my expectation isn't what happened.)

In what way is that an unreasonable question?

Evan




More information about the Python-list mailing list