midstr(X;Y;Z)
Extracts up to Z characters starting at the
Yth character from the end of the string. (Available as of version 16.09)
Syntax
midstr(X;Y;Z)
Input
| Argument | Type | Description |
|---|---|---|
X |
text | The string on which to apply the function A scalar value or the name of a column |
Y |
integer | For positive values of Y, the position from the beginning of string
X to begin the string extraction.
For negative values of Y,
position from the end of string X
to begin the string extraction. |
Z |
integer | The number of characters to extract from
the string. Fewer than Z
characters may be returned if the end of the
string is reached. You can omit Z
if you want to return the string from the
Yth character to the end of the
string. |
Return Value
For positive values of Y, returns a text string starting at the
Yth position of X and
continuing for Z characters.
For negative values of Y, returns a text string starting
at the Yth position from the end of
X, and continuing for Z
characters.
Sample Usage
value |
position |
number |
midstr(value;position;number) |
|---|---|---|---|
| 'testing' | 3 | 3 | 'sti' |
| 'testing' | -3 | 3 | 'ing' |
| 'testing' | 5 | 5 | 'ing' |
| 'testing' | -4 | 'ting' |
Additional Information
midstr(X;Y;Z) is similar to
strextract(X;P;N), but
midstr(X;Y;Z) may be more convenient for certain
applications, such as when porting code from other languages.