split. Splitting a string

^string.split[delimiter]
^string.split[delimiter;splitting options]
^string.split[delimiter;splitting options;column name]
   [3.2.2]

The method splits
string into substrings using delimiter substring and creates an object of class table, containing:
·either a table with single column, where it places the resulted parts,  
·or a nameless table where resulted parts are columns of single row.  

Splitting options include:
l-split from left to right (default);
r-split from right to left;
h-form nameless table with resulted parts placed horizontally;
v-form table with single column, where resulted parts are placed vertically (default).

The name of column for vertical split-"
piece" or the column name passed as a parameter.

Example of using vertical split
$str[Strangers in the night…]
$parts[^str.split[
the]]
^parts.save[parts.txt]

The code in the example will create file
parts.txt containing…

piece
Strangers in 
 night…

Example of using horizontal split
$str[/a/b/c/d]
$parts[^str.split[
/;lh]]
$parts.0, $parts.1, $parts.2

…outputs:
, a, b


Copyright © 1997–2021 Art. Lebedev Studio | http://www.artlebedev.com Last updated: 28.08.2007