strpick(X;Y;I)

Returns the character at a particular position, or the element delimited by a particular value, within a given string.

Syntax

strpick(X;Y;I)
bstrpick(X;Y;I)

Input

Argument Type Description
X text The string on which to apply the function

A scalar value or the name of a column

Y text The character or string to be used as the delimiter in X

A scalar value or the name of a column

I integer An index corresponding to the particular character or substring in X

The index I is 1-based (i.e., the first occurrence has index 1).

A negative index counts back from the end of the string (i.e., I=-1 refers to the last element or character).

A scalar value or the name of a column

Return Value

If Y is non-empty, this function splits the string X using Y as a delimiter and returns the I'th delimited element. If Y is empty, it returns the I'th character of X.

If X or I is N/A, the result is N/A. If I=0, the result is N/A. If Y is N/A, the result is the I'th character of X.

Sample Usage

value delimiter index strpick(value;delimiter;index)
'apple,banana,cherimoya' ',' 2 'banana'
'foo--bar--baz' '--' -1 'baz'
'foo--bar--baz' '' -3 'b'

Additional Information

  • strpick is Unicode (UTF-8) compliant and will work with Unicode or plain ASCII text fields.
  • If passed a string argument that is not legal Unicode, it will by default signal an error (configurable as a user preference).
  • A corresponding function bstrpick can be used with non-Unicode strings (e.g., binary or legacy encodings).