REGEXMATCH Function in Google Sheets: Syntax, Examples & Compatibility
Learn how to check whether a text value follows a predictable identifier pattern 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: check whether a text value follows a predictable identifier pattern 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 REGEXMATCH reference. Documentation check, not a new native test; existing example-verification notes retain their scope.
Syntax and arguments
=REGEXMATCH(text, regular_expression)
Both arguments are required. Google specifies text input and a logical TRUE/FALSE result. The pattern can match a substring unless its anchors require the entire input. A TRUE result verifies only the pattern that was actually supplied, not an unstated business rule.
Best use case: Check whether a text value follows a predictable identifier pattern.
Set up the example sheet
Suppose invoice identifiers should have three letters, a hyphen and exactly three digits. Check a valid and invalid string with anchored patterns.
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: REGEXMATCH with known input
=REGEXMATCH("INV-204","^[A-Z]{3}-[0-9]{3}$")
Expected output: TRUE.
The identifier contains three capital letters followed by exactly three digits.
Worked example 2: a second REGEXMATCH case
=REGEXMATCH("INV-20","^[A-Z]{3}-[0-9]{3}$")
Expected output: FALSE.
Only two digits follow the hyphen, so the anchored pattern does not match.
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.
Test the whole identifier and its near misses
The original anchored rule requires three uppercase ASCII letters, a hyphen, and three ASCII digits. Check this small table with =REGEXMATCH(A2,"^[A-Z]{3}-[0-9]{3}$") filled down:
| Input text | Expected result |
|---|---|
| INV-204 | TRUE |
| INV-20 | FALSE |
| inv-204 | FALSE |
| INV-2040 | FALSE |
| XINV-204 | FALSE |
| INV-004 | TRUE |
The leading zeros in INV-004 are valid characters under this rule. No numerical conversion is needed. To accept only the literal INV prefix, use ^INV-[0-9]{3}$; the broader original pattern also accepts ABC-204.
Advanced example: substring matching changes the question
=REGEXMATCH("note INV-204 paid","[A-Z]{3}-[0-9]{3}")
=REGEXMATCH("note INV-204 paid","^[A-Z]{3}-[0-9]{3}$")
Expected results are TRUE and FALSE. The first asks whether a code-shaped substring exists; the second asks whether the whole input is a code.
The examples have no newline characters or changed multiline flags. Anchoring behavior should be reviewed again when the application deliberately accepts multiline fields.
Advanced example: group alternatives before anchoring
To accept either an invoice or a purchase-order prefix:
=REGEXMATCH("PO-007","^(INV|PO)-[0-9]{3}$")
Expected result: TRUE. The same pattern accepts INV-204 and rejects XPO-007, PO-07, and QUOTE-007. Parentheses apply the surrounding prefix/suffix requirements to both alternatives. They do not make REGEXMATCH return captured text; its output remains logical.
Literal punctuation and explicit text conversion
=REGEXMATCH("AB.204","^AB\.204$")
=REGEXMATCH("ABX204","^AB\.204$")
Expected results are TRUE and FALSE. The escaped dot is literal; an unescaped dot is a pattern metacharacter.
For a genuinely numeric input, =REGEXMATCH(TEXT(204,"0"),"^[0-9]{3}$") has expected result TRUE under the stated English-style number format. That formula explicitly decides how the number becomes text. A numeric 4 cannot reveal whether its original imported identifier was 4, 04 or 004 without additional information.
The rule checks form only. A code that matches may still be absent from the authoritative register; a separate lookup answers that question.
Practical advice and troubleshooting
When this formula helps: Use ^ and $ anchors for whole-cell validation; without them a regex may match just part of a longer string.
Important edge case: Google Sheets regex uses RE2 conventions and requires text input. Convert numeric inputs to text before applying textual patterns.
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
Excel desktop has newer regex-related functions in selected releases but does not treat REGEXMATCH as a universal Excel-compatible formula.
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.
Related guides and official documentation
To explore more examples, start at the software function directory.
- Google Sheets documentation for REGEXMATCH — dedicated function syntax and Google-specific behavior.
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.