String Replace with Regular Expressions Example

The following example demonstrates the use of the string replace viper with regular expressions. The strings being replaced must start with an 'r' or 'm' character, followed by the string sequence "ai" and this sequence must be followed by at least one word character.  All matching strings will be replaced with an '*' character.

Smartsite SXML CopyCode image Copy Code
{string.replace('The rain in Spain falls mainly in the plain','(r|m)ai(\w+)', '*', UseRegExp)}
Example Result CopyCode image Copy Code
The * in Spain falls * in the plain
SXML