strextract(X;P;N)

Returns the specified number of characters, starting at a certain position, extracted from a given string.

Syntax

strextract(X;P;N)
bstrextract(X;P;N)

Input

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

A scalar value or the name of a column

P integer An index corresponding to a particular position in X

The index P is 1-based (i.e., the first character has position 1).

A negative position counts back from the end of the string (i.e., P=-1 refers to the last character).

N integer The number of characters to extract from X

N=-1 refers to as many characters as necessary to reach the end of the string.

If N is N/A, it is treated as -1.

Return Value

Returns the text value consisting of N characters beginning at position P extracted from the string X.

If X or P is N/A, the result is N/A.

Sample Usage

value position number strextract(value;position;number)
'testing' 2 3 'est'
'testing' -5 -1 'sting'

Additional Information

  • strextract 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 bstrextract can be used with non-Unicode strings (e.g., binary or legacy encodings).