You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ant.apache.org by bu...@apache.org on 2003/06/09 19:41:15 UTC

DO NOT REPLY [Bug 20618] New: - class org.apache.tools.ant.util.regexp.Jdk14RegexpMatcher

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=20618>.
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=20618

class org.apache.tools.ant.util.regexp.Jdk14RegexpMatcher 

           Summary: class
                    org.apache.tools.ant.util.regexp.Jdk14RegexpMatcher
           Product: Ant
           Version: 1.5.2
          Platform: PC
        OS/Version: Windows XP
            Status: NEW
          Severity: Major
          Priority: Other
         Component: Optional Tasks
        AssignedTo: dev@ant.apache.org
        ReportedBy: james.treacy@c24.biz


The matches() method in this class uses the Pattern.find() method incorrectly, 
leading to pattern matching behaviour that differs wildly from the pattern 
matching behaviour in JDK 1.4 which I assume it is meant to copy.  It should 
use the Pattern.matches() method instead to get a more accurate result.  For 
example: line 116 of Jdk14RegexpMatcher


public boolean matches(String input, int options)
        throws BuildException {
        try {
            Pattern p = getCompiledPattern(options);
            return p.matcher(input).find();
        } catch (Exception e) {
            throw new BuildException(e);
        }
    }

the current code will return true if I am looking for a match to the pattern [0-
9] {0,2} and my search String is 6M whilst "6M".match("[0-9] {0,2}") will 
return false.  Jdk14RegexpMatcher.matches() returns true because it uses the 
looser find() method. I would be extremely grateful if a fix for this bug could 
be implemented in the near future, which makes use of the tighter matches() 
method.

kind regards

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org