bug-classpath
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Bug classpath/25837] New: gnu.regexp: Difference in the capturing opera


From: kaz at maczuka dot gcd dot org
Subject: [Bug classpath/25837] New: gnu.regexp: Difference in the capturing operation
Date: 18 Jan 2006 02:58:13 -0000

Test program:
$ cat W.java
import java.util.regex.*;
public class W {
  public static void main(String[] args) throws Exception {
    int flags = 0;
    if (System.getProperty("CASE_INSENSITIVE") != null) {
      flags |= Pattern.CASE_INSENSITIVE;
    }
    Pattern p = Pattern.compile(args[1], flags);
    Matcher m = p.matcher(args[0]);
    boolean b = m.matches();
    System.out.println(b);
    if (b) {
      int groups = m.groupCount();
      for (int i = 0; i <= groups; i++) {
        System.out.println("G" + i + " = " + m.group(i));
      }
    }
  }
}

Test case (taken from Mauve gnu/testlet/java/util/regex/Pattern/testdata2):
$ java W 'bbbc' '^(b+|a){1,2}c'
true
G0 = bbbc
G1 = b

Expected results:
Sun's JDK:
$ java W 'bbbc' '^(b+|a){1,2}c'
true
G0 = bbbc
G1 = bbb

Perl:
$ perl -e 'if ("bbbc" =~ /^(b+|a){1,2}c/) {print $&."\n"; print $1."\n";}'
bbbc
bbb

Mauve gnu/testlet/java/util/regex/Pattern/testdata2:
    bbbc
 0: bbbc
 1: bb
(I think this expected result of Mauve is wrong.)

"bbbc" and "^(b+|a){1,2}c" can match in several ways. Which is most
desirable?

gnu.regexp:
  bb : (b+|a)
  b  : (b+|a)
  c  : c

Sun's JDK and Perl
  bbb : (b+|a)
  c   : c


-- 
           Summary: gnu.regexp: Difference in the capturing operation
           Product: classpath
           Version: unspecified
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: classpath
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: kaz at maczuka dot gcd dot org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25837





reply via email to

[Prev in Thread] Current Thread [Next in Thread]