Returns one or more substrings from a delimited source string based on specified substring indices.
STRIDXGET(idx, "srchstr", "indelimit", "outdelimit", skipempty)
idx |
- |
An integer series. The substring indices. |
||||
"srchstr" |
- |
A string. The source string to search. |
||||
"indelimit" |
- |
Optional. A string specifying the characters used to separate srchstr into individual substrings. Defaults to space, tab, newline or comma. |
||||
"outdelimit" |
- |
Optional. A string specifying the characters used to separate the returned substrings. If "indelimit" is provided, defaults to "indelimit" else defaults to a space character. |
||||
skipempty |
- |
Optional. An integer, ignore empty substrings.
|
A delimited string.
a = strget({1, 3}, "YOR:12.3 XINC:1.0 YREF:120.0")
a == YOR:12.3 YREF:120.0, the first and third space delimited substrings.
By default, substrings are delimited by spaces. Set "indelimit" to specify specific delimiter characters.
a = stridxget({1, 3}, "YOR:12.3 XINC:1.0 YREF:120.0",":");
b = stridxget({1, 3}, "YOR:12.3 XINC:1.0 YREF:120.0",":", ",");
a == YOR:1.0 YREF
The first and third substrings where : is the input and output separator character.
b == YOR,1.0 YREF
The first and third substrings where : is the input separator and , is the output separator character.
By default, empty substrings are ignored. The skipempty parameter explicitly sets the empty substring behavior.
s1 = stridxget({2, 3}, "aaa,,ccc,ddd", ",");
s2 = stridxget({2, 3}, "aaa,,ccc,ddd", ",", 1);
s3 = stridxget({2, 3}, "aaa,,ccc,ddd", ",", 0);
s4 = stridxget({1, 2, 3}, "aaa,,ccc,ddd", ",", 0);
s1 == "ccc,ddd"
s2 == "ccc,ddd"
s3 == ",ccc"
s4 == "aaa,,ccc"
The empty delimited substring is ignored for s1 and s2.
The empty delimited substring is processed for s3 and s4.
See STRGET to return a single substring given an integer index.