Skip to content

matchesRegex placeholder - regex with comma #306

@pvgpe

Description

@pvgpe

Using a matchesRegex placeholder with a regex containing a comma (,) requires configuring a different placeholderArgsSeparatorRegex so the regex is not splitted in two arguments.

For example

<a>${xmlunit.matchesRegex(.{300,400})}</a>

would results in just .{300 used as a regex (which would fail to be parsed as a regex Pattern in this case)

This might not be obvious without inspecting the library code,
It also seems to me that it's mixing internal parsing of the placeholder depending on the argument value used.

Suggestion:

  • require quotes around arguments? would not be backwards compatible
  • make the arguments parsing / splitting placeholder-specific? e.g. matchesRegex would take the whole string and not split it?
  • document the behavior in https://github.com/xmlunit/user-guide/wiki/Placeholders / unit tests linked from there

Note I didn't test if there is a similar problem with ) inside the regex.

Related: wiremock/wiremock#3094

Please feel free to close if this is expected and the library used should use the proper constructor and configure the placeholderArgsSeparatorRegex

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions