This is documentation for Mathematica 8, which was
based on an earlier version of the Wolfram Language.
View current documentation (Version 11.1)

StringMatchQ

StringMatchQ
tests whether matches the string pattern patt.
StringMatchQ["string", RegularExpression["regex"]]
tests whether matches the specified regular expression.
StringMatchQ
gives the list of results for each of the .
  • 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 specifies the verbatim string , with and treated literally.
Test whether a string pattern matches a particular string:
Use abbreviated string patterns:
Test whether a string pattern matches a particular string:
In[1]:=
Click for copyable input
Out[1]=
 
Use abbreviated string patterns:
In[1]:=
Click for copyable input
Out[1]=
Use string patterns:
Use a regular expression:
Use pattern matching for dates:
Mixed regular expressions and string patterns:
StringMatchQ automatically threads over lists of strings:
With IgnoreCase -> True, uppercase and lowercase are treated the same:
The option SpellingCorrection -> True allows automatic spelling correction:
Find all words that contain double letters:
For literal strings, SameQ is equivalent to StringMatchQ:
For fast extraction of elements in a list, use Pick:
Compare to Select:
Use StringFreeQ to check no substring matches a pattern:
StringMatchQ returns False whenever StringFreeQ is True:
StringMatchQ does not work on strings with embedded formatting information:
Spelling correction only works for letter string patterns:
New in 1 | Last modified in 5.1