REGEXEXTRACT pulls the first part of a text value that matches a pattern. It works well when IDs, prices, domains, or tags appear at different positions in each row.
For example, =REGEXEXTRACT(A2,"\d+") extracts the first uninterrupted run of digits from A2.
REGEXEXTRACT Function Syntax in Google Sheets
=REGEXEXTRACT(text, regular_expression)
- text is the string or cell to search.
- regular_expression describes the text to return.
Without parentheses, REGEXEXTRACT returns the full match. One capture group returns that group. Multiple capture groups return multiple columns.
Sheets uses Google’s RE2 syntax. Lookaround assertions and backreferences used in some regex engines are unavailable.
When to Use REGEXEXTRACT
- Pull a number or code from mixed text.
- Extract the domain from an email address.
- Return the first word of a phrase.
- Convert a price embedded in a sentence.
- Extract text between brackets or other markers.
Extract Digits From Text
Cell A2 contains Order ID: AB-2048, total $49.95. Use:
=REGEXEXTRACT(A2,"\d+")
\d matches one digit, while + extends the match through consecutive digits. The tested result is 2048.
Return Multiple Capture Groups
=REGEXEXTRACT(A2,"([A-Z]{2})-(\d{4})")
The first group captures two uppercase letters. The second captures four digits. The tested result spills AB and 2048 into adjacent cells.

Pull the Domain From an Email
Cell A3 contains Email: rita.khan+sales@example.co.uk. The domain begins after the at sign and runs to the end:
=REGEXEXTRACT(A3,"@([^ ]+)$")
The parentheses return only the captured text, excluding the at sign. The tested result is example.co.uk.
Grab the First Word
=REGEXEXTRACT(A2,"^\w+")
The caret anchors the match at the start. \w+ then captures consecutive letters, digits, or underscores until another character appears.
If imported text begins with spaces, wrap A2 with TRIM or use a pattern that allows leading whitespace.
Extract a Price and Convert It to a Number
=VALUE(REGEXEXTRACT(A2,"\$(\d+\.\d{2})"))
\$ matches the dollar sign. \d+ captures whole-number digits, and \. matches a literal decimal point.
The tested result is the number 49.95. Adjust the pattern if your source uses commas, optional decimals, negative signs, or another currency format.
Extract Text Between Brackets
Cell A4 contains Tags: [urgent] [finance]. Use a negated character class to stop at the first closing bracket:
=REGEXEXTRACT(A4,"\[([^\]]+)\]")
The tested result is urgent. Escaped brackets match the literal markers, while the capture group returns the text inside them.
Handle Missing Matches and Numeric Inputs
No matching text returns #N/A. Put IFNA around the formula when a missing pattern is expected and you want a blank or label.
A numeric input returns #VALUE!. Convert it first:
=REGEXEXTRACT(TO_TEXT(A6),"\d+")
The tested result for numeric 12345 is the text 12345.
Use REGEXMATCH to test whether a pattern exists and REGEXREPLACE to change matching text.
Google’s REGEXEXTRACT reference covers capture groups, input types, and the RE2 engine.
Other Google Sheets articles you may also like