@WORD[["sep_list",]n,string] : Returns the nth word in string. The first (leftmost) word is numbered 0. If n is negative, words are counted backwards from the end of string, and the absolute value of n is used. You can specify the rightmost word by setting n to -0.
You can specify a range of words to return with the syntax:
@WORD[["sep_list",]start[-end | +range],string]
Specify an inclusive range with a -. For example:
%@word[2-4,A B C D E F G] will return "C D E". (Note that you cannot use inclusive ranges when starting from the end.)
You can specify a relative range with a +. For example:
%@word[2+1,A B C D E F G] will return "C D".
If you use a - and don't specify an end, @WORD will return all words from the nth one to the end of the line. For example:
%@word[2-,A B C D E F G] will return "C D E F G".
The default list of separators for @FIELD, @FIELDS, @WORD and @WORDS consists of space, tab, and comma. You can use the optional first parameter, sep_list, to specify the separators that you wish to use. If you want to use a quote mark as a separator, prefix it with an Escape character. Alphabetic characters in sep_list are case sensitive.
@FIELD and @FIELDS differ from @WORD and @WORDS in how multiple consecutive separators are counted. @WORD and @WORDS consider a sequence as a single separator, and ignore separators at either end of string. In contrast, @FIELD and @FIELDS count each occurrence of a separator individually, including those at either end of string.
Numeric input may be entered in either decimal format (a sequence of 0-9 digits) or in hexadecimal format ("0x" followed by a sequence of 0-F hex digits). To use hexadecimal form for a negative n, remember to use 32-bit 2's complement arithmetic, e.g., 0xFFFFFFFF for -1.
See also: @WORDS, @FIELD, @FIELDS.
Examples:
function |
value |
%@WORD[2,NOW, , , IS THE TIME] |
THE |
%@WORD[-0,NOW IS THE TIME] |
TIME |
%@WORD[-2,NOW IS THE TIME] |
IS |
%@WORD["=",1,2 + 2=4] |
4 |