18.4 Tokenizing

18.4.1 tokenize

Synopsis

tokenize(input-string, delimiter);

Description

The input-string variable is searched for occurrences of delimiter and split into tokens. An array consisting of these tokens is returned. If separator is not found tokenize () returns an empty array; you can use this information to understand whenever separator has been found or not.

Both input-string and delimiter can be any valid expression.

Example

tokens [] = tokenize ("foo/bar/pamela.cws", "/");
i=0;
foreach (item in tokens []) {
  print ("Token n. " + i + ": " + item);
  i++;
}

This is Cows output:

Token n. 0: foo
Token n. 1: bar
Token n. 2: pamela.cws

This manual can be downloaded from http://www.g-cows.org/.