DO NOT REPLY [Bug 16461] New: - Broken non-greedy regular expressions.

[email protected]
Newsgroups gmane.comp.jakarta.oro.devel
Message-ID <[email protected]>
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=16461>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=16461

Broken non-greedy regular expressions.

           Summary: Broken non-greedy regular expressions.
           Product: ORO
           Version: 2.0.6
          Platform: Other
        OS/Version: Other
            Status: NEW
          Severity: Critical
          Priority: Other
         Component: Main
        AssignedTo: [email protected]
        ReportedBy: [email protected]


The problem was found in Jython by several programmers, but it looks like ORO's
fault. I replaced Jython's ORO with ORO 2.0.7 - the result is the same.

 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#'
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.