StringMatchQ["string",patt]
tests whether "string" matches the string pattern patt.
StringMatchQ[{s1,s2,…},p]
gives the list of results for each of the si.
Details and Options
- StringMatchQ allows both ordinary StringExpression string patterns, as well as abbreviated string patterns containing the following metacharacters:
-
* zero or more characters @ one or more characters, excluding uppercase letters \\*, etc. literal *, etc. - Verbatim["p"] specifies the verbatim string "p", with * and @ treated literally.
- Setting the option IgnoreCase->True makes StringMatchQ treat lowercase and uppercase letters as equivalent.
- Setting the option SpellingCorrection->True makes StringMatchQ allow strings to match even if a small fraction of their characters are different.
- StringMatchQ[form][expr] is equivalent to StringMatchQ[expr,form].
Examples
open allclose allBasic Examples (3)
Test whether a string pattern matches a particular string:
Use abbreviated string patterns:
Use the operator form of StringMatchQ:
Scope (5)
Use pattern matching for dates:
Mixed regular expressions and string patterns:
StringMatchQ automatically threads over lists of strings:
Options (2)
IgnoreCase (1)
With IgnoreCase -> True, uppercase and lowercase are treated the same:
SpellingCorrection (1)
Properties & Relations (3)
Possible Issues (2)
StringMatchQ does not work on strings with embedded formatting information:
Spelling correction only works for letter string patterns: