[Python-bugs-list] [Bug #111705] problems with re.py and regex.py

noreply@sourceforge.net noreply@sourceforge.net
Mon, 28 Aug 2000 00:49:16 -0700


Bug #111705, was updated on 2000-Aug-11 12:19
Here is a current snapshot of the bug.

Project: Python
Category: None
Status: Closed
Resolution: Works For Me
Bug Group: Irreproducible
Priority: 5
Summary: problems with re.py and regex.py

Details: Hi, here is something I have been working on for quite some time. I always thought it was my regex syntax, but I was incorrect. I tried it in perl, and php, and both worked fine.

re.py has a problem with ([_a-zA-Z0-9-]\.*) where it hangs during compilation.
regex.py has a problem with ([a-zA-Z]){2,3} (or any other similar statement) where it does not limit the number of characters properly.

Here is the code
...
import string
import sys
import regex

def testemailaddr(emailaddr):
	pattern = regex.compile('^([_a-zA-Z0-9-]\.*){3,255}@([_a-zA-Z0-9-]\.*){3,255}\.([a-zA-Z]){2,3}$')
	if pattern.match(emailaddr) != None:
		valid = [1, emailaddr]
	else:
		valid = [0, emailaddr]
	return valid

validemail = testemailaddr(sys.argv[1])
if validemail[0] == 1: print validemail[1], "is valid."
else: print validemail[1], "is not valid."

Follow-Ups:

Date: 2000-Aug-28 00:49
By: effbot

Comment:
'regex' doesn't support {} repeat syntax (see the docs for details).

and the given pattern doesn't hang during compilation, whether I'm using 1.5.2's re module (the PCRE engine), 1.6's re module (SRE), or 1.6's pre module (PCRE).

to reopen this bug, please submit an example that includes a sample target string (emailaddr).
-------------------------------------------------------

For detailed info, follow this link:
http://sourceforge.net/bugs/?func=detailbug&bug_id=111705&group_id=5470