STRGET

Purpose:

Returns the nth substring of a search string.

Syntax:

STRGET(num, "srchstr", "delimit", ignore)

num

-

An integer. The number of the substring to return.

"srchstr"

-

A string. The search string to search in.

"delimit"

-

Optional. A string specifying the characters used to separate srchstr into individual substrings. Defaults to a space delimiter character.

ignore

-

Optional. An integer, ignore empty substrings.

0:

process an empty substring

1:

ignore an empty substring (default)

Returns:

A string.

Example:

strget(2, "YOR:12.3 XINC:1.0 YREF:120.0")

 

returns: XINC:1.0 because that is the second substring.

Example:

By default, substrings are delimited by spaces. Set "delimit" to specify specific delimiter characters.

 

strget(2, "YOR:12.3 XINC:1.0 YREF:120.0",":")

 

returns: 12.3 XINC because the : is the separator character.

Example:

By default, empty substrings are ignored. The ignore parameter explicitly sets the empty substring behavior.

 

s1 = strget(2, "aaa,,ccc,ddd", ",");

s2 = strget(2, "aaa,,ccc,ddd", ",", 1);

s3 = strget(2, "aaa,,ccc,ddd", ",", 0);

 

s1 == "ccc"

s2 == "ccc"

s3 == ""

 

t1 = strget(3, "aaa,,ccc,ddd", ",");

t2 = strget(3, "aaa,,ccc,ddd", ",", 1);

t3 = strget(3, "aaa,,ccc,ddd", ",", 0);

 

t1 == "ddd"

t2 == "ddd"

t3 == "ccc"

 

The empty delimited substring is ignored in s1, s2, t1, t2 and processed in s3 and t3.

See Also:

STRCAT

STRCMP

STREXTRACT

STRFIND

STRMATCH

STRREPLACE

STRSORT