splits "string" into a list of substrings separated by whitespace.

splits into substrings separated by delimiters matching the string expression patt.

splits at any of the pi.

inserts val at the position of each delimiter.

inserts vi at the position of each delimiter pi.

splits into at most n substrings.

gives the list of results for each of the si.

Details and OptionsDetails and Options

  • StringSplit[s] does not return the whitespace characters that delimit the substrings it returns.
  • Whitespace includes any number of spaces, tabs, and newlines.
  • The string expression patt can contain any of the objects specified in the notes for StringExpression.
  • StringSplit[s] is equivalent to StringSplit[s,Whitespace].
  • If s contains two adjacent delimiters, StringSplit considers there to be a zerolength substring "" between them.
  • StringSplit[s,patt] by default gives the list of substrings of s that occur between delimiters defined by patt; it does not include the delimiters themselves.
  • StringSplit[s,patt->val] includes val at the position of each delimiter.
  • StringSplit[s,patt:>val] evaluates val only when the pattern is found.
  • StringSplit["string",{p1->v1,,pa,}] includes v1 at the position of delimiters matching p1, but omits delimiters matching pa.
  • By default, StringSplit[s,patt] drops zerolength substrings associated with delimiters that appear at the beginning or end of s.
  • StringSplit[s,patt,All] returns all substrings, including zerolength ones at the beginning or end.
  • Setting the option IgnoreCase->True makes StringSplit treat lowercase and uppercase letters as equivalent.
  • StringSplit["string",RegularExpression["regex"]] splits at delimiters matching the specified regular expression.
Introduced in 2004