Wolfram ResearchPRODUCTSPURCHASEFOR USERSCOMPANYOUR SITES
THIS IS DOCUMENTATION FOR AN OBSOLETE PRODUCT.
SEE THE DOCUMENTATION CENTER FOR THE LATEST INFORMATION.

StringMatchQ

StringMatchQ is used to check whether a whole string matches a certain pattern.

In[45]:= 

Out[45]=

In[46]:= 

Out[46]=

StringMatchQ is special in that it also allows the metacharacters * and @ to be entered as wildcards (for backwards compatibility reasons). * is equivalent to ShortestMatch[___] (RegularExpression["(?s).*?"]) and @ is equivalent to Except[CharacterRange["A","Z"]] (RegularExpression["[^A-Z]"]).

The following three patterns are therefore equivalent.

In[47]:= 

Out[47]=

In[48]:= 

Out[48]=

In[49]:= 

Out[49]=

Note that technically the appearance of ShortestMatch does not make a difference here, since we are only looking for a possible match.

If you need to access parts of the string matched by subpatterns in the pattern, use StringCases instead.

StringMatchQ has a SpellingCorrection option for finding matches allowing for a small number of discrepancies. This only works for patterns consisting of a single literal string.

In[50]:= 

Out[50]=


Any questions about topics on this page? Click here to get an individual response.Buy NowFree TrialMore Information



 © 2009 Wolfram Research, Inc.  Terms of Use  Privacy Policy |
Sign up for our newsletter: