Message1204
Hi,
I have problems with reqexp. I'm using Jython 2.2a1. I
tried these with
java1.4.2_04 and java1.5.0_06. Could someone tell, are
these bugs or am I
just doing something wrong?
First one is here:
import re
START_ITEM = "< ITEM >"
END_ITEM = "< END ITEM >"
TEXT = "1234567890"
_ITEM_RE = re.compile('''
<\s*ITEM\s*> # Start
\s*(.*?)\s* # Body (group 1)
<\s*END\s+ITEM\s*> # End
''' % locals(), re.VERBOSE | re.DOTALL)
string = '%s%s%s%s' % (START_ITEM, 200*TEXT, END_ITEM,
1*TEXT)
# Find text inside item and after it
res = _ITEM_RE.search(string)
inside_the_match = res.group(1)
after_match = string[res.end():]
actual = (inside_the_match, after_match)
expected = (200*TEXT, 1*TEXT)
assert actual == expected, "%s\n!=\n%s" % (actual,
expected)
When this is executed with Jython, the group does not
contain correct data
nor the after match part. With Python this works just fine.
Other one is this kind:
import re
START_ITEM = "<ITEM>"
END_ITEM = "<END ITEM>"
TEXT = "1234567890"
pattern = '%s(.*?)%s' % (START_ITEM, END_ITEM)
string = '%s%s%s%s' % (START_ITEM, 200*TEXT, END_ITEM,
1*TEXT)
# Find text inside item and after it
res = re.search(pattern, string)
inside_the_match = res.group(1)
after_match = string[res.end():]
actual = (inside_the_match, after_match)
expected = (200*TEXT, 1*TEXT)
assert actual == expected, "%s\n!=\n%s" % (actual,
expected)
Problem with this is that following RuntimeError is raised:
Traceback (innermost last):
File "bug.py", line 11, in ?
File "C:\APPS\jython2-2a1\Lib\sre.py", line 137, in
search
RuntimeError: maximum recursion limit exceeded
Again with Python this works just fine.
So it would be nice if someone could test and check are
these bugs. If
these are, are these already fixed in Jython 2.2beta?
Best Regards,
Juha Rantanen |
|
Date |
User |
Action |
Args |
2008-02-20 17:17:32 | admin | link | issue1541338 messages |
2008-02-20 17:17:32 | admin | create | |
|