What REGEXMATCH Does
REGEXMATCH tests whether a text string matches a regular expression pattern and returns TRUE or FALSE. It is far more powerful than simple text comparisons because regular expressions can describe complex patterns — phone number formats, email structures, specific prefixes, or any combination of characters. Use it to validate data, build conditional logic, or filter rows based on pattern matching.
Syntax
=REGEXMATCH(text, regular_expression)
| Parameter | Description |
|---|---|
| text | The string to test. |
| regular_expression | The regex pattern to match against, enclosed in quotes. |
REGEXMATCH returns TRUE if any part of the text matches the pattern. It does not need to match the entire string unless you anchor it with ^ and $.
Basic Examples
Check if a cell contains a number
| A | B | |
|---|---|---|
| 1 | Value | Has Number? |
| 2 | Order #4521 | =REGEXMATCH(A2, "\d") |
| 3 | Pending | =REGEXMATCH(A3, "\d") |
Results:
| Has Number? |
|---|
| TRUE |
| FALSE |
The \d pattern matches any digit.
Validate email format
| A | B | |
|---|---|---|
| 1 | Valid? | |
| 2 | alex@company.com | =REGEXMATCH(A2, "^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+.[a-zA-Z]{2}$") |
| 3 | not-an-email | =REGEXMATCH(A3, "^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+.[a-zA-Z]{2}$") |
Results:
| Valid? |
|---|
| TRUE |
| FALSE |
Check if text starts with a specific prefix
| A | B | |
|---|---|---|
| 1 | Code | Is SKU? |
| 2 | SKU-4410 | =REGEXMATCH(A2, "^SKU-") |
| 3 | INV-2201 | =REGEXMATCH(A3, "^SKU-") |
Results:
| Is SKU? |
|---|
| TRUE |
| FALSE |
The ^ anchor ensures the match starts at the beginning of the string.
Advanced Examples
Filter rows using REGEXMATCH in a FILTER function
Pull only rows where the description contains a year (four consecutive digits):
=FILTER(A2:C100, REGEXMATCH(B2:B100, "\b(19|20)\d{2}\b"))
The pattern \b(19|20)\d{2}\b matches four-digit years from 1900 to 2099 as whole words. Combined with FILTER, this returns only rows where column B mentions a year — useful for separating dated entries from undated ones.
Match one of several keywords
To check if a cell contains any of a list of words:
=REGEXMATCH(LOWER(A2), "urgent|critical|blocker")
This returns TRUE if A2 contains "urgent", "critical", or "blocker" (case-insensitive thanks to LOWER). The pipe character | acts as OR in regex. You could use this to auto-flag high-priority support tickets.
Common Mistakes
- Forgetting that REGEXMATCH is case-sensitive.
=REGEXMATCH("Hello", "hello")returns FALSE. To make it case-insensitive, either wrap the text in LOWER or add(?i)at the start of the pattern:=REGEXMATCH(A1, "(?i)hello"). - Not escaping special regex characters. Characters like
.,*,+,(,),[, and\have special meaning in regex. To match a literal period, use\.instead of just.. For example, matching a file extension:=REGEXMATCH(A1, "\.pdf$"). - Assuming the entire string must match. REGEXMATCH returns TRUE if the pattern appears anywhere in the text.
=REGEXMATCH("abc123", "\d")is TRUE because there are digits in the string. To require a full-string match, use^and$anchors:=REGEXMATCH(A1, "^\d+$")matches only if the entire string is digits.
SheetAI Tip
Don't want to memorize this syntax? With SheetAI, just type what you need in plain English and the formula is generated for you. Install SheetAI to try it free.