Type: Function
Function: REGEX_EXTRACT
Syntax: REGEX_EXTRACT(string, regex)
Description: Extracts the first matching substring according to a regular expression.
The regex must be a POSIX regular expression. You can use this tool to test your regular expressions.
Note that backslashes (\) need to be escaped in strings. So typical regex patterns such as \d will have to be written \\d in regex strings. See the examples below.
Sample usage:
REGEX_EXTRACT("foo123", "\\d+")returns"123".REGEX_EXTRACT("v1.2.34", "\\d+\\.\\d+")returns"1.2"REGEX_EXTRACT("v1.2", "\\d+\.\\d+(\\.\\d+)?")returns"1.2"REGEX_EXTRACT("v1.2.34", "\\d+\\.\\d+(\\.\\d+)?")returns"1.2.34"REGEX_EXTRACT("Some title #123", "#\\d+")returns"#123"REGEX_EXTRACT("Some title #123", "#(\\d+)")returns"123". In this case, only the capture specified by the parentheses is retained, but the#is still useful for matching the pattern before the extraction is made.
βRegular Expression cheat sheet.:
"^fix"string starts with "fix""fix$"string ends with "fix""fix|bug"string contains "fix" or "bug"Test more regular expressions using this tool
