Bug 3753 - RE matches when it shouldn't
Summary: RE matches when it shouldn't
Status: CLOSED INVALID
Alias: None
Product: Regexp
Classification: Unclassified
Component: Other (show other bugs)
Version: unspecified
Hardware: PC All
: P3 major (vote)
Target Milestone: ---
Assignee: Jakarta Notifications Mailing List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2001-09-20 14:07 UTC by Alex Miller
Modified: 2005-03-20 17:06 UTC (History)
0 users



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Alex Miller 2001-09-20 14:07:01 UTC
The following sample program return true, but should return false.  Perhaps the 
escaped '.' is being interpreted unescaped and matching the 'x' in the str?

Sample program
--------------
import org.apache.regexp.*;

public class Test { 
  public static void main(String arg[]) {
    try {
      String pattern = ".*\\.";
      String str = ".x";
      RE re = new RE(pattern);
      System.out.println(re.match(str));        // should be false
    } catch(Exception e) {
      e.printStackTrace();
    }
  }
}
Comment 1 Daniel F. Savarese 2001-09-20 14:37:03 UTC
match() does not require the entire input to match.  It attempts to match
some portion of the input.  The pattern ".*\\." does in fact match the "."
in ".x"  If you want the entire input to match, try "^.*\\.$" as your
pattern.
Comment 2 Vadim Gritsenko 2003-05-02 01:29:47 UTC
closed