This is documentation for Mathematica 8, which was
based on an earlier version of the Wolfram Language.
 BUILT-IN MATHEMATICA SYMBOL Tutorials »| See Also »| More About »

# StringCases

 StringCasesgives a list of the substrings in that match the string expression patt. StringCasesgives a list of the values of rhs corresponding to the substrings that match the string expression lhs. StringCasesincludes only the first n substrings that match. StringCasesgives substrings that match any of the . StringCasesgives the list of results for each of the .
• String expressions can contain any of the objects specified in the notes for StringExpression.
• With Overlaps->All, multiple substrings that match the same string expression are all included. With Overlaps->True, only the first such matching substring at a given position is included.
• StringCases evaluates rhs only when the pattern is found.
Find the substrings matching a pattern:
Return only the named wild-card character in each substring:
Find the substrings matching a pattern:
 Out[1]=

Return only the named wild-card character in each substring:
 Out[1]=
 Scope   (8)
Use string patterns:
Use a regular expression:
Use pattern matching for dates:
Mixed regular expressions and string patterns:
Rules to extract values corresponding to matching substrings:
Include only the two first strings that match:
Occurrences in either substring:
StringCases automatically threads over lists of strings:
 Options   (2)
Find all substrings "cat", including use of uppercase letters:
Find all runs of two or more letters starting with the letter "a":
Allow overlaps between the substrings:
Allow multiple substrings to start at the same character as well:
 Applications   (3)
Extract phone numbers from a text:
Find the sequence of section numbers in the U.S. Constitution:
Find the numbers of amendments to the Constitution:
Primes whose digits are all consecutive:
StringCount gives the number of matching substrings:
The length of matching substrings:
Use StringPosition to get the position of matching substrings:
Check:
Use rather than if the right-hand side of a rule contains string operations:
Using in such cases leads to immediate evaluation and possible error messages:
Find the sequence of words in the U.S. Constitution:
Total number of words:
Number of distinct words:
Logarithmic frequency distribution of words:
Ten most common words:
New in 5.1