This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: LibRef 4.2.1: {m,n} description update
Type: Stage:
Components: Documentation Versions:
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: akuchling Nosy List: akuchling, terry.reedy
Priority: normal Keywords:

Created on 2003-02-24 04:30 by terry.reedy, last changed 2022-04-10 16:07 by admin. This issue is now closed.

Messages (3)
msg14792 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2003-02-24 04:30
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."
msg14793 - (view) Author: A.M. Kuchling (akuchling) * (Python committer) Date: 2003-03-04 14:23
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.
msg14794 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2003-03-04 16:17
Logged In: YES 
user_id=593130

Yes: this is consistent with pre's deprecation and removal 
from re.py (after 2.2.1) and the recent removal (since 
2.2.2), from Lib Sect 4.2, of the Implementation Note 
discussing sre versus pre.
History
Date User Action Args
2022-04-10 16:07:03adminsetgithub: 38037
2003-02-24 04:30:37terry.reedycreate