Issue668194

classification
Title: broken non greedy regular expressions
Type: Severity: normal
Components: Library Versions:
Milestone:
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: bckfnn Nosy List: bckfnn, trelony
Priority: normal Keywords:

Created on 2003-01-14.23:19:18 by trelony, last changed 2003-02-12.11:01:53 by bckfnn.

Files
File name Uploaded Description Edit Remove
test.jy trelony, 2003-01-14.23:21:03 test case
Messages
msg811 (view) Author: Alexey N. Solofnenko (trelony) Date: 2003-01-14.23:19:18
In the following test the first block matching
([^":]*?) contains quotas, but if expression is
([^":]*), it does not match at all. Greedy modifier
cannot affect operation success.

Test program:

import re

s='"file.name" "path/file"'
s2=re.sub(r'^"([^":]*)/([^":/\\]*)"', r'1 #\1#\n2 #\2#', s)
s3=re.sub(r'^"([^":]*?)/([^":/\\]*)"', r'1 #\1#\n2
#\2#', s)

print
"s='"+s+"'\n\n============================\ns2='"+s2+"'\n\n============================\ns3='"+s3+"'"


output (s2 is not changed - no match; s3's first block
contains quotas):

s='"file.name" "path/file"'

============================
s2='"file.name" "path/file"'

============================
s3='1 #file.name" "path#
2 #file#'
msg812 (view) Author: Finn Bock (bckfnn) Date: 2003-02-12.11:01:53
Logged In: YES 
user_id=4201

Already fixed in CVS.
History
Date User Action Args
2003-01-14 23:19:18trelonycreate