Skip to main content

Text.split

splitdelimitercase_sensitivityuse_regex

Group: Conversions
Aliases: split text

Documentation

Takes a delimiter and returns the vector that results from splitting self on each of its occurrences.

Arguments

  • delimiter: The pattern used to split the text.
  • case_sensitivity: Specifies if the text values should be compared case sensitively. The values are compared case sensitively by default.
  • use_regex: If true, the term is used as a regular expression.

Examples

Split the text on any occurrence of the separator "::".

      text = "Namespace::package::package::Type"
text.split "::" == ["Namespace", "package", "package", "Type"]

Split the text on a regex pattern.

      "abc--def==>ghi".split "[-=>]+" use_regex=True == ["abc", "def", "ghi"]

Split the text on any whitespace.

      'abc  def\tghi'.split '\\s+' use_regex=True == ["abc", "def", "ghi"]

Split with a vector of strings.

      'azbzczdzezfzg'.split ['b', 'zez'] == ['az', 'zczd', 'fzg']