The Fauna service will be ending on May 30, 2025.

For more information on the service wind down, see our announcement and the Fauna Service End-of-Life FAQ.

string.replaceAllRegex()

Replace all occurrences of substrings matching a regular expression in a String.

Signature

replaceAllRegex(pattern: String, replacement: String) => String

Description

Replaces all occurrences of substrings matching a regular expression in the calling String with a provided replacement.

Returns a new String. The calling String isn’t changed.

Parameters

Parameter Type Required Description

pattern

String

true

Regular expression to match in the calling String. Supports Java regex.

replacement

String

true

Replacement for matches in the calling String.

Return value

Type Description

String

Resulting String with replacements.

Examples

fqlCopied!
"1234".replaceAllRegex('\\w', 'abc-')
"abc-abc-abc-abc-"
\