Navigation :
fieldr
fieldr, function
def const pure fieldr(haystack: text, separator: text, n: number): text
Returns the nth field (zero-indexed, from the right) in haystack, separated
by separator.
haystack: text to split.
separator: delimiter between fields.
n: zero-based field index from the right.
Examples
table T = with
[| as Haystack, as Separator, as N |]
[| "a-b-c-d", "-", 0 |]
[| "a-b-c-d", "-", 2 |]
[| "a--c-d", "-", 2 |]
[| "a", "-", 2 |]
T.Field = fieldr(T.Haystack, T.Separator, T.N)
show table "Fields" with
T.Haystack
T.Separator
T.N
T.Field
This produces the following table:
| Haystack |
Separator |
N |
Field |
| a-b-c-d |
- |
0 |
d |
| a-b-c-d |
- |
2 |
b |
| a–c-d |
- |
2 |
|
| a |
- |
2 |
|
If separator is empty or n is negative, fieldr returns an empty text.
See also