String Functions, continued
$Piece has additional features. $Piece can return a range of pieces, rather than a single piece. It can return pieces from the same string based on different delimiters. $Piece returns the empty string if there's an empty piece (nothing before the first delimiter, or two delimiters in a row).
$Piece is important because it allows you to use a single string that contains multiple substrings, with a special delimiter character (such as “^”) to separate them. The large string acts as a record, and the substrings are its fields. Also, note that $Length has a piece-oriented variant: it returns the number of pieces in a string based on a delimiter.
SAMPLES>write $piece("slice of pizza", " ", 1, 2) slice of SAMPLES>write $piece("slice of pizza", "i", 2) ce of p SAMPLES>write $piece("slice of pizza", "z", 2) SAMPLES>set city=$piece("One Memorial Drive^Cambridge^MA^02142", "^", 2) SAMPLES>write city Cambridge SAMPLES>write $length("slice of pizza", " ") 3 SAMPLES>