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

StringCount

StringCount
gives a count of the number of times appears as a substring of .
StringCount
gives the number of substrings in that match the general string expression patt.
StringCount
counts the number of occurrences of any of the .
StringCount
gives the list of results for each of the .
  • The string expression patt can contain any of the objects specified in the notes for StringExpression.
  • With the default option setting Overlaps->False, overlapping substrings are not treated as separate. With the setting Overlaps->True, StringCount counts substrings that overlap as separate.
  • With Overlaps->All, multiple substrings that match the same string expression are all counted as separate. With Overlaps->True, only the first such matching substring at a given position is counted as separate.
The number of occurrences of in the string :
Count the number of substrings of the form for different x characters:
The number of occurrences of in the string :
In[1]:=
Click for copyable input
Out[1]=
 
Count the number of substrings of the form for different x characters:
In[1]:=
Click for copyable input
Out[1]=
Use string patterns:
Regular expressions:
Mixed regular expressions and string patterns:
Count occurrences of either substrings:
StringCount automatically threads over lists of strings:
The number of occurrences of in :
Ignore case:
All substrings in starting and ending with :
StringCount does not include overlaps by default:
This includes the overlaps:
This includes overlaps starting at the same position:
A 10-million-base random DNA string:
The number of sequences with adenine symmetrically placed:
Find how many words occur in the U.S. Constitution:
The number of occurrences of the word :
All strings made of two characters with length 4 and which overlap themselves:
StringCount gives the number of matching substrings:
The length of matching substrings obtained from StringCases:
New in 5.1