Skip to content

or() with capture() #32

Description

@Tavio

It seems to me that the following expression:

VerbalExpression testRegex = regex()
                .capture()
                .find("abc")
                .or("def")
                .build();

should evaluate to the regex: /(?:((?:abc)|(?:(?:def))))/, but instead it evaluates to: /(?:((?:abc))|(?:(?:def)))/. As a result, if we test this expression against the string "def" it produces a match but no group is captured. This happens because the implementation of or() closes any opening parenthesis it finds in the string that precedes it.

I don't know why or() was implemented this way, but I believe the implementation of oneOf() I propose in #31 may fix this problem.

Metadata

Metadata

Assignees

No one assigned

    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