+ in regular expression

contro opinion contropinion at gmail.com
Wed Oct 3 23:01:17 EDT 2012


>>> str="          gg"
>>> x1=re.match("\s+",str)
>>> x1
<_sre.SRE_Match object at 0xb7354db0>
>>> x2=re.match("\s{6}",str)
>>> x2
<_sre.SRE_Match object at 0xb7337f38>
>>> x3=re.match("\s{6}+",str)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python2.6/re.py", line 137, in match
    return _compile(pattern, flags).match(string)
  File "/usr/lib/python2.6/re.py", line 245, in _compile
    raise error, v # invalid expression
sre_constants.error: multiple repeat
>>>

why the  "\s{6}+"  is not a regular pattern?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20121003/e039c0f9/attachment.html>


More information about the Python-list mailing list