extend.split

extend.split(T.Source : text, S.Separator : text) 🡒 U.*, table function

Generates all the tokens obtained by splitting the source text values according to specificed separators. Empty tokens are omitted. The first argument must be the source text values. The second argument must be the separators. The returned table contains two vectors Token : text and Position : number.

table Phrases = with
  [| "|blue berry|fruit" as X |]
  [| "fast|||red||fox" |]
  [| "big  t i ger " |]

table Separators = with
  [| " " as S |]
  [| "|" |]

table T = extend.split(Phrases.X, Separators.S)
T.Check = substr(Phrases.X, T.Position, strlen(T.Token))

show table "Tokens" a1c10 with
  Phrases.X
  T.Token
  T.Position
  substr(Phrases.X, T.Position, strlen(T.Token)) // matches 'T.Token'

The table function fails if:

Signature

/// Create a list of tokens splitting input text values.
/// Empty tokens are omitted. Max 100 separators.
tablefunc extend.split<Phrases,Separators>(
    /// Input text value to be split.
    Phrases.Source : text,
    /// Table must not be empty. Separator must not be empty text.
    Separators.Separator : text
) : {
    /// The non-empty token.
    Token : text,
    /// The index of the first char in the original text value.
    Position : number
} as "extend.split"