gives a count of the number of times "sub" appears as a substring of "string".
gives the number of substrings in "string" that match the general string expression patt.
counts the number of occurrences of any of the patti.
gives the list of results for each of the si.
Details and Options
- 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.
- Setting the option IgnoreCase->True makes StringCount treat lowercase and uppercase letters as equivalent.
- StringCount["string",RegularExpression["regex"]] gives the number of substrings matching the specified regular expression.
- StringCount[BioSequence["type","seq"],patt] counts the matches of patt in the string "seq". In this case, degenerate letters in patt are interpreted as wildcard patterns based on the type of bio sequence. Use Verbatim["patt"] to match degenerate letters literally.
- If the bio sequence operated upon by StringCount is circular, wraparound matches are possible.
Examplesopen allclose all
Basic Examples (2)
StringCount automatically threads over lists of strings:
Use Verbatim to restrict degenerate letter matching to exact matches:
StringCount does not include overlaps by default:
Wolfram Research (2004), StringCount, Wolfram Language function, https://reference.wolfram.com/language/ref/StringCount.html (updated 2020).
Wolfram Language. 2004. "StringCount." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2020. https://reference.wolfram.com/language/ref/StringCount.html.
Wolfram Language. (2004). StringCount. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/StringCount.html