Skip to content

Incorrect match found when capturing groups are not used #93

@EricEdens

Description

@EricEdens

This test passes when using java.util.regex, but fails with re2j:

  @Test
  public void test() {
    Pattern p1 = Pattern.compile("(a.*?c)|a.*?b");
    Pattern p2 = Pattern.compile("a.*?c|a.*?b");

    Matcher m1 = p1.matcher("abc");
    m1.find();
    Matcher m2 = p2.matcher("abc");
    m2.find();

    assertEquals(m1.group(), m2.group());
  }

Both expressions should match abc. The second one only matches ab.

Fixed in go: golang/go#13812

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions