Category: FUNCTION | Updated: 2026-11-22
How to Use the REGEXMATCH Function in Google Sheets | Check Pattern Matches with Regular Expressions
How to Use the REGEXMATCH Function
The REGEXMATCH function is a Google Sheets text function that checks whether a given text string matches a regular expression pattern and returns a boolean value (TRUE or FALSE).
Syntax
=REGEXMATCH(text, regular_expression)
- text: The text string or cell reference (e.g.,
A2) to test (required). - regular_expression: The regular expression pattern to match against, enclosed in double quotation marks (
") (required).
Examples
Here are examples of validating postal code formats and checking for specific keywords in input data.
| Row | Column A (Input Data) | Column B (Match Result) | Formula Used |
|---|---|---|---|
| 1 | Input Data | Match Result | Formula Used |
| 2 | 060-0001 | TRUE |
=REGEXMATCH(A2, "^[0-9]{3}-[0-9]{4}$") |
| 3 | 0600001 | FALSE |
=REGEXMATCH(A3, "^[0-9]{3}-[0-9]{4}$") |
| 4 | Tokyo, Shibuya | TRUE |
=REGEXMATCH(A4, "^(Tokyo|Osaka|Hokkaido)") |
| 5 | user@example.com | TRUE |
=REGEXMATCH(A5, "^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$") |
- Formula in B2:
=REGEXMATCH(A2, "^[0-9]{3}-[0-9]{4}$")→ ReturnsTRUEbecause it exactly matches the format of 3 digits, a hyphen, and 4 digits. - Combining with IF: Using
=IF(REGEXMATCH(A2, "^[0-9]{3}-[0-9]{4}$"), "OK", "Format Error")lets you build input validation checks.
Common Errors and Tips
- Partial matches return
TRUEby default:REGEXMATCHreturnsTRUEif the pattern appears anywhere within the text. To verify that the entire string matches the pattern, always wrap the expression with^(start) and$(end). - Referencing numeric or date cells causes
#VALUE!: If the target cell contains a number, referencing it directly produces a#VALUE!error. Append&""to convert it to text first, such as=REGEXMATCH(A2&"", "^[0-9]+$"). - Escape special characters to match them literally: Metacharacters like dot (
.), question mark (?), plus (+), and parentheses (()) must be escaped with a backslash (\), such as\., to be matched as literal characters.
Frequently Asked Questions
Q. How can I make REGEXMATCH case-insensitive?
A. Add "(?i)" to the beginning of your regular expression, like "=REGEXMATCH(A2, "(?i)apple")". This will return TRUE for Apple, APPLE, or apple.
Q. How do I check for an exact full-string match with REGEXMATCH?
A. Add "^" at the start and "$" at the end of the pattern, such as "=REGEXMATCH(A2, "^[0-9]{3}-[0-9]{4}$")". Without these anchors, REGEXMATCH returns TRUE as long as the pattern appears anywhere inside the text.