Contact

REGEXEXTRACT Function in Google Sheets: Syntax, Examples & Compatibility

Text Beginner Google Sheets

Learn how to pull a structured code out of a longer piece of text in Google Sheets. Includes syntax, two verified-by-reasoning results, troubleshooting and portability notes.

Verification status: See the evidence and test scope described in this guide. How formula examples are checked

Quick answer: pull a structured code out of a longer piece of text in Google Sheets. The reproducible examples below use explicit values so the formula’s meaning is testable without a large workbook.

Evidence: The function name and syntax are documented in the linked vendor function reference. Expected outputs were independently reasoned or checked outside the application. These are not native Google Sheets test results. A guide being published here does not certify every software release or file-import scenario.

Availability and version history

  • Introduced: Introduction version not established by the official history reviewed.
  • Availability: Documented in the rolling Google Sheets service; examples use the web spreadsheet workflow.
  • Checked: October 14, 2026; official REGEXEXTRACT reference. Documentation check, not a new native test; existing example-verification notes retain their scope.

Syntax and arguments

=REGEXEXTRACT(text, regular_expression)

Both arguments are required. Google says the function extracts the first matching case. Without capture groups it returns the complete match; parenthesized capture groups can return separate results in multiple columns.

The input and output are text. Convert numeric input deliberately with TEXT when needed; use VALUE afterward only if the extracted characters are meant to become a number. Identifiers often need their leading zeros preserved.

Best use case: Pull a structured code out of a longer piece of text.

Set up the example sheet

Start with a purchase-order note containing both narrative text and a repeated SKU-like identifier.

Enter the formula in an unused cell. For a formula returning several values, leave an unobstructed area where those values can expand. These formulas use comma argument separators in a typical English-language locale; commas or semicolons inside quoted text are data, not argument separators. Adapt the separator if your regional settings require it.

Worked example 1: REGEXEXTRACT with known input

=REGEXEXTRACT("Order AB-204 paid","[A-Z]{2}-[0-9]{3}")

Expected output: AB-204.

The pattern matches two capital letters, a hyphen and three digits.

Worked example 2: a second REGEXEXTRACT case

=REGEXEXTRACT("AB-204","[0-9]{3}")

Expected output: 204 as text.

Only the three-digit portion of the code matches the pattern.

Compare both results before replacing literal values or short sample ranges with your own workbook data. For a spilling formula, compare every output cell, not only the top-left result.

Extract the first occurrence, not every occurrence

=REGEXEXTRACT("AB-204 then CD-105","[A-Z]{2}-[0-9]{3}")

Expected text: AB-204. The second code also fits the pattern, but REGEXEXTRACT does not return both code occurrences from this call. A capture group changes which pieces of that first match are returned, not the number of matching occurrences searched across the string.

Advanced example: return two fields from one code

=REGEXEXTRACT("Order AB-004 paid","([A-Z]{2})-([0-9]{3})")

The complete expected result is one row by two columns: AB | 004. The first parentheses capture the prefix and the second capture the digits. The hyphen is matched but not captured. Leave two result cells clear; the displayed headings in this explanation are not extra output cells.

With only the digits captured:

=REGEXEXTRACT("Order AB-004 paid","[A-Z]{2}-([0-9]{3})")

Expected text: 004, not the complete AB-004 code. If the number four is actually needed, =VALUE(REGEXEXTRACT("AB-004","[0-9]{3}")) has expected numeric result 4. That conversion loses the identifier’s leading zeros by design.

Advanced example: distinguish a substring from a validated field

For the text XXAB-204ZZ, the unanchored [A-Z]{2}-[0-9]{3} pattern can extract AB-204 from the middle. This does not certify the entire source as a valid two-letter code.

Use =REGEXMATCH("XXAB-204ZZ","^[A-Z]{2}-[0-9]{3}$") to check the whole field: the expected result is FALSE. The same anchored test on AB-204 is TRUE. Extraction and validation answer different questions.

Keep pattern breadth explicit

[0-9]+ means one or more ASCII digits. On A12 B345, the first match is text 12. On A007 B8, it is 007. The + lets lengths vary; {3} asks for exactly three matched digits.

These examples use plain ASCII text and ordinary nonempty matches. An optional unmatched group, no-match error, malformed expression and Unicode-class boundary require separate evidence. Do not convert every error to an empty label and then treat it as proof that no code was present.

Practical advice and troubleshooting

When this formula helps: Use a capturing group if you want a specific subpart; document the regex so the next person understands which formats are allowed.

Important edge case: Use REGEXMATCH to check whether the intended pattern occurs. The dedicated REGEXEXTRACT prose reviewed does not specify the complete no-match/error-code behavior; broad IFERROR handling would also hide unrelated formula errors.

If the result differs, first verify the text-versus-number types of the input cells, the argument separators for your locale, and the range size. For dynamic arrays, inspect occupied cells in the output area. For an imported file, check that the formula is being evaluated in Google Sheets and that its ranges and text survived conversion.

Compatibility and version considerations

Google Sheets REGEXEXTRACT is not the same as Calligra REGEXP or Excel TEXTAFTER; argument order and pattern flavor require review.

Google Sheets is a rolling web service. Confirm the sheet locale and the full result area when checking an imported formula.

Function availability and parameter behavior must be judged for the specific application and release; a function documented in one spreadsheet does not automatically work in another.

RE2 scope

Google documents RE2 with Unicode character-class matching excluded in Sheets. The RE2 syntax reference supports the ASCII classes, grouping, repetition and anchors used here. Lookaround and backreferences inside a pattern are not supported by RE2. These controls do not certify other engines, arbitrary Unicode, replacement-group syntax or native error displays.

Editorial verification: Full dedicated reference and current manuscript reviewed October 14, 2026. Original and added outputs were independently calculated; no native application run, screenshot, or version-specific output is claimed. Review the editorial testing standards if you require stronger proof before importing a workbook.