Mathematica 9 is now available

StringCount

Usage

StringCount["string", "sub"] gives a count of the number of times "sub" appears as a substring of "string".
StringCount["string", patt] gives the number of substrings in "string" that match the general string expression patt.
StringCount["string", { ,  , ... }] counts the number of occurrences of any of the  .
StringCount[{ ,  , ... }, p] gives the list of results for each of the  .


Notes

• Example: StringCount["abbaabbaa", "bb"]LongRightArrow .
• The string expression patt can contain any of the objects specified in the notes for StringExpression.
• Example: StringCount["abcadcacb", "a"~~_~~"c"]LongRightArrow .
• With the default option setting Overlaps -> True, StringCount counts as separate substrings that overlap. With the setting Overlaps -> False such substrings are not treated 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.
• Setting the option IgnoreCase -> True makes StringCount treat lower- and upper-case letters as equivalent.
• Example: StringCount["abAB", "a", IgnoreCase -> True]LongRightArrow .
StringCount["string", RegularExpression["regex"]] gives the number of substrings matching the specified regular expression.
• See Section 2.8.2.
• New in Version 5.1.


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.