split. Splitting a string

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

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:
- split from left to right (default);
- split from right to left;
- create a nameless table with resulted parts placed horizontally;
- create a table with single column, where resulted parts are placed vertically (default);
- create an array from parts of the original string. [3.5.0]

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–2025 Art. Lebedev Studio | http://www.artlebedev.com Last updated: 03.01.2025