REGEXMATCH function

Tests whether a text string matches a regular expression pattern; returns TRUE for matches and FALSE for non-matches.

=REGEXMATCH(text, regular_expression)

Generate a REGEXMATCH formula

Describe what you need. The generator will reach for REGEXMATCH where REGEXMATCH is the right tool, and tell you when it is not.

How to get a better answer
  • Name your columns by letter and by header: "column F (Net Value)" beats "the amount column".
  • State every condition, including the negatives — "not cancelled" changes the formula's shape.
  • Say where the data starts if it is not row 1, and whether it will grow.
  • Check the settings above match your spreadsheet: the wrong argument separator is a syntax error on your machine.

Arguments

How REGEXMATCH reads its arguments
textrequiredregular_expressionrequiredREGEXMATCH
ArgumentRequiredDescription
textRequiredThe string to test. If text is a number or formula that returns a number, it's coerced to a string; NULL or empty values are treated as empty strings.
regular_expressionRequiredThe regex pattern to match against. Must be a valid regular expression; common anchors are ^ (start) and $ (end), \d for digits, \w for word characters, and [a-z] for character classes.

Returns

Boolean: TRUE if the text matches the pattern, FALSE otherwise.

Availability

Excel: Not available · Google Sheets: Supported

Worked examples

1. Check if a vehicle ID starts with T or F

VehicleOdometerService DateCostGarage
T-500452302025-01-15$320Mike's Auto
F-221321052025-01-16$150Quick Lube
S-318189452025-02-05$420Downtown Motors
=REGEXMATCH(A2, "^[TF]")

Result: TRUE (for T-500 and F-221); FALSE (for S-318)

The pattern ^[TF] matches any text that starts with either T or F. This is useful for categorizing vehicle types by their ID prefix. Row 2 (T-500) and Row 3 (F-221) both match, while Row 4 (S-318) does not.

2. Validate that a service date is in YYYY-MM-DD format

VehicleOdometerService DateCostGarage
T-500452302025-01-15$320Mike's Auto
F-2213210501/16/2025$150Quick Lube
=REGEXMATCH(C2, "^\d{4}-\d{2}-\d{2}$")

Result: TRUE (for 2025-01-15); FALSE (for 01/16/2025)

The pattern ^\d{4}-\d{2}-\d{2}$ requires exactly four digits, a dash, two digits, a dash, and two more digits—no more, no less. This ensures dates conform to a strict format. The first row passes because the date is exactly YYYY-MM-DD; the second row fails because it uses MM/DD/YYYY instead.

3. Find service records from garages with 'Auto' or 'Motors' in the name

VehicleOdometerService DateCostGarage
T-500452302025-01-15$320Mike's Auto
F-221321052025-01-16$150Quick Lube
S-318189452025-02-05$420Downtown Motors
=REGEXMATCH(E2, "Auto|Motors")

Result: TRUE (for Mike's Auto and Downtown Motors); FALSE (for Quick Lube)

The pipe character (|) means OR in regex, so Auto|Motors matches any text containing either word. This lets you identify service records from specific types of garages without listing every garage name individually. Rows with 'Mike's Auto' and 'Downtown Motors' match; 'Quick Lube' does not.

Common errors

Which REGEXMATCH error are you seeing?
REGEXMATCH returned an error#VALUE!
Review the regex pattern character by character. Ensure all brackets [ ], parentheses ( ), and braces { } are matched in pairs. Use an online regex tester to validate the pattern before using it in your sheet.
#VALUE!
Check your backslash escapes. Common valid sequences are \d (digit), \w (word character), \s (whitespace). For literal characters like a period or asterisk, escape them with a single backslash: \. or \*.
#N/A
Verify that both arguments reference cells with actual values. Use IFERROR to gracefully handle missing data: =IFERROR(REGEXMATCH(A2, "^T"), FALSE).
ErrorWhy it happensHow to fix it
#VALUE!The regular expression contains unmatched or malformed syntax, such as an unclosed bracket, parenthesis, or brace (e.g., =REGEXMATCH(A2, "[TF") missing closing bracket).Review the regex pattern character by character. Ensure all brackets [ ], parentheses ( ), and braces { } are matched in pairs. Use an online regex tester to validate the pattern before using it in your sheet.
#VALUE!The regular expression uses an invalid escape sequence or backreference that the regex engine does not recognize (e.g., \k without a corresponding named group).Check your backslash escapes. Common valid sequences are \d (digit), \w (word character), \s (whitespace). For literal characters like a period or asterisk, escape them with a single backslash: \. or \*.
#N/AThe text or regular_expression argument evaluates to an empty value or references a cell that contains an error or null.Verify that both arguments reference cells with actual values. Use IFERROR to gracefully handle missing data: =IFERROR(REGEXMATCH(A2, "^T"), FALSE).

Tips and when to use something else

  • Use ^ and $ anchors to match the entire string: ^T checks if a string starts with T, while T$ checks if it ends with T. Without them, ^T-\d+ still matches 'VehicleT-500' in the middle.
  • To make pattern matching case-insensitive, Google Sheets does not have a built-in flag; instead, use REGEXMATCH(LOWER(A2), "pattern") or REGEXMATCH(UPPER(A2), "PATTERN").
  • Combine REGEXMATCH with ARRAYFORMULA to check an entire column at once: =ARRAYFORMULA(IF(ROW(A:A)=1, "Starts with T?", REGEXMATCH(A:A, "^T"))).
  • For more complex text extraction (not just TRUE/FALSE), use REGEXEXTRACT instead of REGEXMATCH. If you need to filter rows by pattern, use FILTER with REGEXMATCH as the condition.

Frequently asked questions

How do I find all rows in my fleet log where the vehicle ID contains a specific pattern?
Use FILTER combined with REGEXMATCH: =FILTER(A:E, REGEXMATCH(A:A, "^T")) will return all rows where column A starts with T. REGEXMATCH returns TRUE or FALSE for each row, and FILTER keeps only the TRUE rows.
Can REGEXMATCH match across line breaks or special characters in my data?
Yes, but by default Google Sheets treats each cell as a single line. Special characters like tabs or newlines must be represented explicitly. To match any character including newlines within a single cell, use . with the dot-matches-all behavior available in Google Sheets regex (though limitations apply).
What's the difference between REGEXMATCH and the SEARCH function?
SEARCH finds the position of a substring and is case-insensitive by default; REGEXMATCH checks if a pattern matches and returns TRUE/FALSE. REGEXMATCH is case-sensitive and supports full regex syntax, so it's more powerful for complex pattern matching.
How do I use REGEXMATCH to check if a cost value falls within a certain range?
You can use REGEXMATCH to validate the format or magnitude, such as =REGEXMATCH(D2, "\$[2-9]\d{2}") to match costs $200–$999. However, for numeric comparisons, use IF or comparison operators directly (e.g., =D2>=200) since that is simpler and faster than regex.

Need a different formula?

The full generator is not scoped to one function — describe any spreadsheet problem and it will pick.

Open the formula generator

Reviewed 2026-09-17