tests whether "string" matches the string pattern patt.


tests whether "string" matches the specified regular expression.


gives the list of results for each of the si.


represents an operator form of StringMatchQ that can be applied to an expression.

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].


open allclose all

Basic Examples  (3)

Test whether a string pattern matches a particular string:

Use abbreviated string patterns:

Use the operator form of StringMatchQ:

Scope  (5)

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:

Options  (2)

IgnoreCase  (1)

With IgnoreCase -> True, uppercase and lowercase are treated the same:

SpellingCorrection  (1)

The option SpellingCorrection -> True allows automatic spelling correction:

Applications  (1)

Find all words that contain double letters:

Properties & Relations  (3)

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:

Possible Issues  (2)

StringMatchQ does not work on strings with embedded formatting information:

Spelling correction only works for letter string patterns:

Introduced in 1988
Updated in 2003