Skip to content

Issue in QueryPredicate.Match.test() Regex Check #112

@samiaul

Description

@samiaul

In the method QueryPredicate.Match.test() (line 128), the regex currently uses java.util.regex.Matcher.hasMatch():

return pattern.matcher(text).hasMatch() == isPositive;

However according to the documentation, hasMatch() only indicates whether a previous match was found:
Returns whether this contains a valid match from a previous match or find operation.

Since the matcher is created on the fly and no match or find operation has been performed, this will always return false.

To correctly evaluate whether the entire input matches the pattern, the method matches() should be used instead, as per the Matcher documentation:
Attempts to match the entire region against the pattern.

Suggested fix:

return pattern.matcher(text).matches() == isPositive;

Oh, and thanks for your work !

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions