[]
        
(Showing Draft Content)

REGEXTEST

Summary

The REGEXTEST function allows you to check whether any part of the supplied text matches a regular expression ("regex"). It returns TRUE if it does, and FALSE if it doesn't.

Syntax

=REGEXTEST(text, pattern, [case_sensitivity])

Arguments

Argument

Description

text

(required)

The text or the reference to a cell containing the text you want to match against.

pattern

(required)

The regular expression ("regex") that describes the pattern of text you want to match.

case_sensitivity

Determines whether the match is case-sensitive.

0: (default) Case sensitive

1: Case insensitive

Remarks

Return: TRUE or FALSE. The regex test result.

Examples

=REGEXTEST("abc","a") // TRUE
=REGEXTEST("abc","[A-Z]") // FALSE
=REGEXTEST("abc","[A-Z]", 1) // TRUE
=REGEXTEST("abc","[0-9]") // FALSE

The REGEXTEST function is compatible with Excel's REGEXTEST. At the same time, the previous version of the SJS.REGEXMATCH function has been deprecated, while maintaining backward compatibility. A list of differences between the two functions is as follows:


REGEXTEST Function

SJS.REGEXMATCH Function

argument types

Only supports 0 or 1 to specify if the match is case-sensitive.

=REGEXTEST("abc","[A-Z]", 1)

Uses the string modifier.

=SJS.REGEXMATCH("abc","[A-Z]", "i")

match in multiline

Only regex matching can be used

=REGEXTEST("abc

ABC","\n[A-Z]")

Can work with the modifier “m”

=SJS.REGEXMATCH("abc

ABC","^[A-Z]","m")

process non-string arguments

Accepts all types.

=REGEXTEST(2024,24)

Returns the #VALUE! for the non-string input.