REGEXEXTRACT

REGEXEXTRACT(text, pattern [,return_mode] [,case_sensitivity])

Returns the characters that match a regular expression.

textThe text string.
patternThe regular expression.
return_mode(Optional) The type of string you want to return:
0 = The first string that matches the pattern (default)
1 = All the strings that match the pattern as an array
2 = The capturing groups from the first match as an array.
case_sensitivity(Optional) A logical value indicating whether to ignore the case:
0 = Case sensitive (default)
1 = Not case sensitive

REMARKS
* This is a Preview Function which means the signature and results may change before being officially released.
* For an illustrated example refer to the page under Advanced Functions
* This function was added in Microsoft 365.
* This function will always return text (left aligned).
* If the "pattern" does not exist in the "text", then #N/A! is returned.
* You can use the REGEXREPLACE function to return the text string after replacing characters that match the pattern provided.
* You can use the REGEXTEST function to return True or False depending if the pattern matches any part of a text string.
* This function was first released in June 2024.
* link - insider.microsoft365.com/en-us/blog/new-regular-expression-regex-functions-in-excel
* For the Microsoft documentation refer to support.microsoft.com
* For the Google documentation refer to support.google.com

 A
1=REGEXEXTRACT("25 London Road", "[0-9]+") = 25
2=REGEXEXTRACT("Mat Taylor (123) 456-7890", "[0-9()]+ [0-9-]+", 1) = (123) 456-7890
3=REGEXEXTRACT("Call 222-567-1234 to book", "\d{3}-\d{3}-\d{4}") = 222-567-1234
4=REGEXEXTRACT("Starting on 12/03/2025", "\b\d{1, 2}/\d{1, 2}/\d{2, 4}\b") = 45728
5=REGEXEXTRACT("Call 222 567 1234 to book", "\d{3}-\d{3}-\d{4}") = #N/A

1 - Extract the numbers from the text string. Pattern - "[0-9]+"
2 - Extract the phone number from the text string. Pattern - "[0-9()]+ [0-9-]+".
3 - Extract the phone number from the text string. Pattern - "\d{3}-\d{3}-\d{4}"
4 - Extract the date from the text string. Pattern - "\b\d{1,2}/\d{1,2}/\d{2,4}\b"
5 - If the pattern cannot be found, then #N/A! is returned. The phone number does not contain any dashes.

© 2025 Better Solutions Limited. All Rights Reserved. © 2025 Better Solutions Limited Top