[Python-bugs-list] [ python-Bugs-692016 ] LibRef 4.2.1: {m,n} description update
SourceForge.net
noreply@sourceforge.net
Tue, 04 Mar 2003 06:23:33 -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: Closed
>Resolution: Fixed
Priority: 5
Submitted By: Terry J. Reedy (tjreedy)
>Assigned to: A.M. Kuchling (akuchling)
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."
----------------------------------------------------------------------
>Comment By: A.M. Kuchling (akuchling)
Date: 2003-03-04 09:23
Message:
Logged In: YES
user_id=11375
Fixed in rev. 1.95 of libre.tex; thanks! I haven't mentioned sre vs. pre,
because that's an implementation detail and 'pre' is likely to go away one of these versions.
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=692016&group_id=5470