Match Text | TEXT_MATCH


TEXT_MATCH( [value], [search] )


The TEXT value

The TEXT value to be searched for. It may also be a string representing a regular expression to match using a pattern.

Return Value

A LIST of TEXT values that are the matched results.


Extract a part or parts of a TEXT value.


TEXT_MATCH() # returns []
TEXT_MATCH("", "") # returns [""]
TEXT_MATCH("", "") # returns []
TEXT_MATCH("apple banana", "/ba\\w+/") # returns ["banana"]
TEXT_MATCH("Apple Banana", "/ba\\w+/i") # returns ["Banana"]
When the `g` flag is present, each result is returned as an array
TEXT_MATCH("Sam Charles Sarah", "/sa\\w+/ig") # returns [["Sam"], ["Sarah"]]
It can also be used with matching groups, in which case the full match is the first result and all matched groups are the subsequent results.
TEXT_MATCH("Once upon a midnight dreary", "/a (.+) (.+)/")
# returns ["a midnight dreary", "midnight", "dreary"]
You can use the `g` flag and capturing groups together
TEXT_MATCH("The lion sat on a lime", "/li(\w{2})/g")
# returns [["lion", "on"], ["lime", "me"]]