StringCases
Usage
• StringCases["string", patt] gives a list of the substrings in "string" that match the string expression patt. • StringCases["string", lhs -> rhs] gives a list of the values of rhs corresponding to the substrings that match the string expression lhs. • StringCases["string", p, n] includes only the first n substrings that match. • StringCases["string", { , , ... }] gives substrings that match any of the . • StringCases[{ , , ... }, p] gives the list of results for each of the .
Notes
• String expressions can contain any of the objects specified in the notes for StringExpression. • Example: StringCases["abcadcacb", "a"~~_~~"c"]  . • Example: StringCases["abcadcacb", "a"~~x_~~"c" -> x]  . • 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 lower- and upper-case 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. • New in Version 5.1.
|