Skip to content

OOME when group matches empty string #16

@mschaefers

Description

@mschaefers

The following code snippet leads to an endless loop in matcher.namedGroups() and eventually to an OutOfMemoryError:

com.google.code.regexp.Matcher matcher = com.google.code.regexp.Pattern.compile("(?<foo>.*)").matcher("bar");
System.out.println(matcher.namedGroups());

Tested with v0.2.6

I would expect that

  1. the expression (?<foo>.*) matched the whole String bar once, because .* is greedy (as opposed to .*?)
  2. no endless loop / OOME occurs, for any given pattern

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions