REGEXMATCH function in Google Sheets
REGEXMATCH checks whether text contains a match for a regular expression and returns TRUE or FALSE. Use it to test a format, such as a valid order code, or to look for any of several words at once with a pattern like refund|return.
- Works in
- Google Sheets only
- Returns
- TRUE if the pattern matches part of the text, FALSE if it doesn't.
Syntax
=REGEXMATCH(text, regular_expression)
| Argument | Required? | What it is |
|---|---|---|
text | Required | The text to test. It has to be text: wrap numbers in TO_TEXT. |
regular_expression | Required | The pattern to look for, in RE2 syntax. It can match anywhere in the text unless you anchor it with ^ and $. |
Examples
Each result is calculated from the sample sheet by our formula engine in Sheets mode, the same one that grades the practice.
| Cell | Formula | Result | What it shows |
|---|---|---|---|
| C2 | =REGEXMATCH(B2,"refund|return") | TRUE | Either word matches: | means or |
| C3 | =REGEXMATCH(A3,"^TK-\d{4}$") | FALSE | Checks the whole code is TK- plus exactly four digits; TK-20415 has five |
| C4 | =REGEXMATCH(B4,"(?i)urgent") | TRUE | (?i) ignores capitals, so URGENT matches |
Try it live
This is the sample sheet. Change any value or edit a formula, and the results update.
Practice REGEXMATCH
Graded instantly in Sheets mode, then re-checked on changed data.
Flag refund requests
C2, return TRUE when the message in B2 mentions "refund" or "return", whatever the capitalization. Fill down to C7.Common mistakes
| What you see | Why, and how to fix it |
|---|---|
| #VALUE! on a number | REGEXMATCH only accepts text, so a number such as 90210 gives an error. Convert it first: =REGEXMATCH(TO_TEXT(A2),"^9"). |
| It matches more than you meant | Without anchors the pattern can match anywhere, so "TK-\d{4}" also matches TK-20415. Add ^ and $ to test the whole text. |
| Capital letters don't match | Matching is case-sensitive. Start the pattern with (?i) to ignore case: "(?i)urgent". |
| A pattern copied from another tool gives an error | Sheets uses RE2, which has no lookaheads or backreferences such as (?=...) or \1. Rewrite the pattern, or split the test into two REGEXMATCH calls joined with AND. |
Tips
- Filter rows by pattern: =FILTER(A2:B9,REGEXMATCH(B2:B9,"refund|return")).
- Escape special characters with a backslash: "\." matches a real dot and "\$" a dollar sign.
REGEXMATCH in Excel
Recent Microsoft 365 builds have REGEXTEST for the same job. Other Excel versions have no regular expressions, so a simple "contains" test uses ISNUMBER with SEARCH.
Questions
How do I check if a cell contains one of several words in Google Sheets?
Separate the words with |: =REGEXMATCH(A2,"refund|return|cancel"). Add (?i) at the start to ignore capitals.
How do I use REGEXMATCH on a whole column?
Wrap it in ARRAYFORMULA, =ARRAYFORMULA(REGEXMATCH(B2:B9,"refund")), or use it as a FILTER condition, which takes ranges directly.
Last reviewed October 2026. Every example result on this page is calculated live by the Spreadsheet Practice formula engine in Sheets mode.