REGEXMATCHformula searches for a regular expression pattern within a specified text string, and returns a boolean value of TRUE if the pattern is found, and FALSE if it is not found. This formula is commonly used to check if a string matches a certain pattern or to extract specific information from a text string based on a pattern.
- How to use
- Examples of using
REGEXMATCHformula not working?
- Similar formulas to
REGEXMATCH formula with the syntax shown below, it has 2 required parameters:
- text (required):
The text string to search for the regular expression pattern.
- regular_expression (required):
The regular expression pattern to search for within the text string. The pattern must be enclosed in quotes.
ExamplesHere are a few example use cases that explain how to use the
REGEXMATCHformula in Google Sheets.
Checking if a string contains a specific pattern
You can use
REGEXMATCH to check if a string contains a certain pattern of characters. For example, you can use this formula to check if an email address is in a valid format by searching for the '@' symbol.
Extracting specific information from a text string
You can use
REGEXMATCH to extract specific information from a text string that matches a certain pattern. For example, you can use this formula to extract all the URLs from a list of text that contains URLs by searching for the 'http' or 'https' pattern.
Validating data entry
You can use
REGEXMATCH to validate data entry in a form or spreadsheet by checking if the input matches a certain pattern. For example, you can use this formula to check if a phone number is in a valid format by searching for a pattern of digits and dashes.
REGEXMATCHnot working? Here are some common mistakes people make when using the
REGEXMATCHGoogle Sheets Formula:
Using incorrect syntax for the regular expression
One common mistake when using
REGEXMATCH is using incorrect syntax for the regular expression. Make sure that your regular expression is formatted correctly and follows the correct syntax for regular expressions.
Forgetting to enclose the regular expression in quotes
Another common mistake when using
REGEXMATCH is forgetting to enclose the regular expression in quotes. Make sure that your regular expression is enclosed in quotes, otherwise it will not be recognized as a string.
Not escaping special characters in the regular expression
If your regular expression contains special characters, such as parentheses or brackets, you need to escape them with a backslash. Otherwise, the regular expression will not work as intended.
The following functions are similar to
REGEXMATCH or are often used with it in a formula:
REGEXEXTRACTformula is used to extract a portion of a text string that matches a regular expression. This is useful when you need to extract specific information from a text string that follows a certain pattern.
REGEXREPLACEformula is used to replace a piece of text that matches a regular expression with a new piece of text. This formula is useful when working with text data that needs to be cleaned or manipulated based on specific patterns or rules.
MATCHformula is used to search for a specified value within a range and returns the relative position of the value within the range. This formula is commonly used in conjunction with the
INDEXformula to retrieve a value from a specific cell in a range. The
search_typeparameter is optional and determines the type of match to be performed, such as exact match, less than, or greater than.
FINDformula in Google Sheets searches for a specific text within another text and returns the position of the first occurrence of the text. This formula is often used to extract a substring from a larger string or to check if a certain text exists within another text.
You can learn more about the
REGEXMATCH Google Sheets function on Google Support.