[Python-bugs-list] [ python-Bugs-692016 ] LibRef 4.2.1: {m,n} description update

SourceForge.net noreply@sourceforge.net
Sun, 23 Feb 2003 20:30:37 -0800


Bugs item #692016, was opened at 2003-02-23 23:30
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=692016&group_id=5470

Category: Documentation
Group: None
Status: Open
Resolution: None
Priority: 5
Submitted By: Terry J. Reedy (tjreedy)
Assigned to: Nobody/Anonymous (nobody)
Summary: LibRef 4.2.1: {m,n} description update

Initial Comment:
LibRef 4.2.1 Regular Expression Syntax 

{m,n} "...you can't omit m...."

Actually, you can: for sre, it defaults to 0

>>> a4=re.compile('a{,4}')
>>> a4.match('').group(0)
''
>>> a4.match('aaaaa').group(0)
'aaaa'

This is predictable from sre_parse.py code
            elif this == "{":
                min, max = 0, MAXREPEAT
                /* lo set to digits between { and ,.*/
                if lo: 
                    min = atoi(lo)
 
Result for pre seems buggy: compiles but does not 
match.  (so 'can't' is sort of correct, but not in way 
expected -- by raising exception):

>>> import pre
>>> pa4=pre.compile('a{,4}')
>>> pa4.match('') # None response
>>> pa4.match('aaaaa').group(0)
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
AttributeError: 'NoneType' object has no 
attribute 'group'

So, suggested replacement:
"For sre, m defaults to 0; for older pre, missing m 
compiles but does not match."

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=692016&group_id=5470