Mathematica 9 is now available
 Documentation / Mathematica / Built-in Functions / Programming / String Manipulation  /
StringMatchQ

  • StringMatchQ[" string ", " pattern "] yields True if string matches the specified string pattern, and yields False otherwise.
  • The pattern string can contain literal characters, together with the metacharacters * and @ specified in Section A.3.13.
  • Example: StringMatchQ["apppbb", "a*b"].
  • Setting the option IgnoreCase -> True makes StringMatchQ treat lower- and upper-case letters as equivalent.
  • Setting the option SpellingCorrection -> True makes StringMatchQ allow strings to match even if a small fraction of their characters are different.
  • See the Mathematica book: Section 2.7.3.
  • See also: StringPosition, Equal, Names, MatchQ.

    Further Examples

    This string matches the pattern "a*b*".

    In[1]:=

    Out[1]=

    These strings do not match.

    In[2]:=

    Out[2]=

    Allowing for spelling correction, the first pair are close enough to match.

    In[3]:=

    Out[3]=

    In[4]:=

    Out[4]=

    These strings match when lower- and upper-case letters are treated as equivalent.

    In[5]:=

    Out[5]=



    Any questions about topics on this page? Click here to get an individual response.Buy NowMore Information
    THIS IS DOCUMENTATION FOR AN OBSOLETE PRODUCT.
    SEE THE DOCUMENTATION CENTER FOR THE LATEST INFORMATION.