+ in regular expression

Evan Driscoll driscoll at cs.wisc.edu
Fri Oct 5 11:31:26 EDT 2012


On 10/05/2012 10:27 AM, Evan Driscoll wrote:
> On 10/05/2012 04:23 AM, Duncan Booth wrote:
>> A regular expression element may be followed by a quantifier.
>> Quantifiers are '*', '+', '?', '{n}', '{n,m}' (and lazy quantifiers
>> '*?', '+?', '{n,m}?'). There's nothing in the regex language which says
>> you can follow an element with two quantifiers.
> In fact, *you* did -- the first sentence of that paragraph! :-)
>
> \s is a regex, so you can follow it with a quantifier and get \s{6}. 
> That's also a regex, so you should be able to follow it with a 
> quantifier.
OK, I guess this isn't true... you said a "regular expression *element*" 
can be followed by a quantifier. I just took what I usually see as part 
of a regular expression and read into your post something it didn't 
quite say. Still, the rest of mine applies.

Evan




More information about the Python-list mailing list