Class: String
Description
This method extracts one or more elements from a delimited string. This method replaces the $PIECE() and $$NPC^%ZS() functions.
Syntax
StringObject.piece(String delimiter,Number first,Number last,
String quoteChar)
Parameters
delimiter |
The character that is used to separate elements within a string. |
first |
The first position of the string to extract. The default value is 1. |
last |
The last position of the string to extract. The default value is the value of first. |
quoteChar |
The quote character. Substrings enclosed by the quote character are ignored. If this parameter is not supplied, or if the empty string is supplied, no special treatment of the quoted substring occurs. |
Returns
A String subfield of a variable.
When Became Available
v6.4
Example
type String STR = "UCGM;08/16/04;PSL#4;7#;PSL compiler"
type String PCE = STR.piece(";") // "UCGM"
set PCE = STR.piece("#",2) // "4;7"
set PCE = STR.piece(";",2,3) // "08/16/04;PSL#4"
set PCE = STR.piece(";",2,3,"#") // "08/16/04;PSL#4;7#"