0
0
Google-sheetsHow-ToBeginner ยท 3 min read

How to Use REGEXMATCH in Google Sheets: Simple Guide

Use the REGEXMATCH function in Google Sheets to check if a cell's text matches a pattern defined by a regular expression. The formula returns TRUE if the pattern matches and FALSE if it does not. Syntax is =REGEXMATCH(text, regular_expression).
๐Ÿ“

Syntax

The REGEXMATCH function has two parts:

  • text: The text you want to check.
  • regular_expression: The pattern you want to find in the text, written as a regular expression.

The function returns TRUE if the pattern is found anywhere in the text, otherwise FALSE.

plaintext
=REGEXMATCH(text, regular_expression)
๐Ÿ’ป

Example

This example checks if the word "apple" appears in cell A1.

If A1 contains "I like apples", the formula returns TRUE. If A1 contains "I like bananas", it returns FALSE.

plaintext
=REGEXMATCH(A1, "apple")
Output
TRUE (if A1 contains "I like apples") or FALSE (if A1 contains "I like bananas")
โš ๏ธ

Common Pitfalls

Common mistakes when using REGEXMATCH include:

  • Not enclosing the regular expression in quotes, which causes errors.
  • Using patterns that don't match the text exactly, like missing case sensitivity.
  • Expecting the function to return the matching text instead of just TRUE or FALSE.

Remember, REGEXMATCH only tells you if the pattern exists, not where or what it matched.

plaintext
=REGEXMATCH(A1, "apple")  <em>(correct)</em>
=REGEXMATCH(A1, apple)  <em>(wrong, missing quotes)</em>
๐Ÿ“Š

Quick Reference

PartDescriptionExample
textThe text to check"I like apples"
regular_expressionPattern to find, in quotes"apple"
ReturnTRUE if pattern found, FALSE if notTRUE or FALSE
โœ…

Key Takeaways

Use REGEXMATCH(text, "pattern") to check if text contains a pattern.
Always put the regular expression inside quotes.
REGEXMATCH returns TRUE or FALSE, not the matched text.
Patterns are case-sensitive unless you use special regex flags.
Test your regex pattern to avoid unexpected results.