Uji nilai untuk pola teks tertentu
=REGEXTEST(text, pattern, [case_sensitivity])
| Parameter | Deskripsi |
|---|---|
text |
The text value to test. |
pattern |
The pattern to test for. |
case_sensitivity |
[optional] 0 = Case sensitive, 1= Case-insensitive. Default is 0. |
To use REGEXTEST, provide text and a pattern. For example, the formulas below show how REGEXTEXT can be used to test the text in A1 for a number or an
=REGEXTEST(A1,"[0-9]") // test for a number
=REGEXTEST(A1,"[A-Z]") // test for an uppercase character
REGEXTEST returns TRUE or FALSE. If we use REGEXTEST to test for "a" in "apple", it returns TRUE:
=REGEXTEST("apple","a") // returns TRUE
If we use REGEXTEST to test "apple" for a single digit between 0-9, it returns FALSE:
=REGEXTEST("apple","[0-9]") // returns FALSE
The worksheet below uses REGEXTEST to test the same string, "1apple23#z", with twelve different patterns. In each formula, the text string comes from
=REGEXTEST(B5,D5)
Let's review the formulas one by one. Note that the formulas below use literal strings instead of cell references for readability. In each case, the t
=REGEXTEST("1apple23#z","apple") // returns TRUE
REGEXTEST returns TRUE because the literal string "apple" appears in the text. Note that REGEXTEST automatically performs a "contains" type search.
=REGEXTEST("1apple23#z","a") // returns TRUE