Match and replace functions

The expression language match and replace functions can match a regular expression or replace it.

The syntax for the replace operation is:

${variable.replace(<match RE>, <replace RE>)}

If the match succeeds, the value is the string with the matched string replaced.

The syntax for a match operation is:

${variable.matches(<match RE>)}

If the match succeeds, the value is true. If it does not, the value is false.

Note The match operation returns a logical value that can be used with relational or conditional operators.

For more about regular expressions, see Regular expressions.

Regular expression examples

The following table shows several examples of using the match and replace operations with regular expressions.

Name Example Example return value
Match ${foo.matches('fo*')} true
Replace ${foo.replace('f(.*)', 'm$1')} moo

Related Links