Replacers are based on a special type of function that scans an input string for substrings matching a regular expression, and then replaces each match with a string returned by a callback.


The syntax is similar to a function call. The difference is that the function name is replaced by a regular expression, and there are exactly two parameters: the first passes in the string to transform, and the second is a callback that is executed whenever a match is found. The text printed within this callback becomes the replacement text for that specific match.

    string to search;
    replacement callback

Accessing match and group values[link]

Use [match] within the replacement callback to print the current match value.

Use [group] within the replacement callback to print the value of a named capturing group.