gives a list of the substrings in "string" that match the string expression patt.
gives a list of the values of rhs corresponding to the substrings that match the string expression lhs.
includes only the first n substrings that match.
gives substrings that match any of the pi.
gives the list of results for each of the si.
Details and Options
- String expressions can contain any of the objects specified in the notes for StringExpression.
- With the default option setting Overlaps->False, StringCases includes only substrings that do not overlap. With Overlaps->True, it includes substrings that overlap.
- 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.
- Setting the option IgnoreCase->True makes StringCases treat lowercase and uppercase letters as equivalent.
- StringCases["string",RegularExpression["regex"]] gives substrings matching the specified regular expression.
- StringCases[s,lhs:>rhs] evaluates rhs only when the pattern is found.
- StringCases[patt][expr] is equivalent to StringCases[expr, patt].
Examplesopen allclose all
Basic Examples (3)
Use the operator form of StringCases: