Skip to main content

Regular Expressions

FunctionDescriptionMeta
regex.find_all_string_submatch_n

output := regex.find_all_string_submatch_n(pattern, value, number)

Returns all successive matches of the expression.

Arguments:
pattern (string)

regular expression

value (string)

string to match

number (number)

number of matches to return; -1 means all matches

Returns:
output (array[array[string]])

array of all matches

Wasm
regex.find_n

output := regex.find_n(pattern, value, number)

Returns the specified number of matches when matching the input against the pattern.

Arguments:
pattern (string)

regular expression

value (string)

string to match

number (number)

number of matches to return, if -1, returns all matches

Returns:
output (array[string])

collected matches

SDK-dependent
regex.globs_match

result := regex.globs_match(glob1, glob2)

Checks if the intersection of two glob-style regular expressions matches a non-empty set of non-empty strings. The set of regex symbols is limited for this builtin: only ., *, +, [, -, ] and \ are treated as special symbols.

Arguments:
glob1 (string)

first glob-style regular expression

glob2 (string)

second glob-style regular expression

Returns:
result (boolean)

true if the intersection of glob1 and glob2 matches a non-empty set of non-empty strings

SDK-dependent
regex.is_valid

result := regex.is_valid(pattern)

Checks if a string is a valid regular expression: the detailed syntax for patterns is defined by https://github.com/google/re2/wiki/Syntax.

Arguments:
pattern (string)

regular expression

Returns:
result (boolean)

true if pattern is a valid regular expression

v0.23.0 Wasm
regex.match

result := regex.match(pattern, value)

Matches a string against a regular expression.

Arguments:
pattern (string)

regular expression

value (string)

value to match against pattern

Returns:
result (boolean)

true if value matches pattern

v0.23.0 Wasm
regex.replace

output := regex.replace(s, pattern, value)

Find and replaces the text using the regular expression pattern.

Arguments:
s (string)

string being processed

pattern (string)

regex pattern to be applied

value (string)

regex value

Returns:
output (string)

string with replaced substrings

v0.45.0 SDK-dependent
regex.split

output := regex.split(pattern, value)

Splits the input string by the occurrences of the given pattern.

Arguments:
pattern (string)

regular expression

value (string)

string to match

Returns:
output (array[string])

the parts obtained by splitting value

SDK-dependent
regex.template_match

result := regex.template_match(template, value, delimiter_start, delimiter_end)

Matches a string against a pattern, where there pattern may be glob-like

Arguments:
template (string)

template expression containing 0..n regular expressions

value (string)

string to match

delimiter_start (string)

start delimiter of the regular expression in template

delimiter_end (string)

end delimiter of the regular expression in template

Returns:
result (boolean)

true if value matches the template

SDK-dependent