Skip to main content
Version: v0.18.0

StringReplace

Alias:StringReplace, RegexReplace

Output:StringStream

Replace every regex match in the string with the result of a particular function

ParameterTypeRequiredPositionDefault ValueSummary
String
In
string1The string to match
Pattern
Find
string2The regular expression pattern. Uses the .net flavor
Replacestring3Either this or 'Function' must be set.The replacement string. Use $1, $2 etc. to replace matched groups
FunctionstringEither this or 'Replace' must be set.A function to take the regex match and return the new string
IgnoreCaseboolFalseWhether the regex should ignore case.

Examples

Example 1

Basic Replacement

SCL

StringReplace String: 'number 1' Find: '1' Replace: 'one'

Expected Output

number one

Example 2

Replace using a function

SCL

StringReplace 'number 1' '\w+' Function: (stringToCase <> TextCase.Upper)

Expected Output

NUMBER 1

Example 3

Replace captured groups

SCL

StringReplace 'number 13' '(\w+)\s+(\d+)' '$2 was your $1'

Expected Output

13 was your number