Mathematica 9 is now available

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"]LongRightArrow .
• Example: StringCases["abcadcacb", "a"~~x_~~"c" -> x]LongRightArrow .
• 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.
• See Section 2.8.4.
• 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.