REGEX

Matches and extracts or optionally replaces text using regular expressions.

Caasima

REGEX( Text ; Expression [ ; [ Replacement ] [ ; Flags ] ] )

Text: A text or reference to a cell where the regular expression is to be applied.

Expression: A text representing the regular expression, using ICU regular expressions. If there is no match, #N/A is returned.

Replacement: Optional. The replacement text and references to capture groups. If there is no match, Text is returned unmodified.

Flags: Optional. "g" replaces all matches of Expression in Text, not extracted. If there is no match, Text is returned unmodified.

Fakkeenyawwan

=REGEX("123456ABCDEF";"[:digit:]";"Z") returns "Z23456ABCDEF", where the first match of a digit is replaced by "Z".

=REGEX("123456ABCDEF";"[:digit:]";"Z";"g") returns "ZZZZZZABCDEF", where all digits were replaced by "Z".

=REGEX("123456ABCDEF";"[1|2|6]";"";"g") returns "345ABCDEF", where any occurrence of "1", "2" or "6" is replaced by the empty string, thus deleted.