@FIELD[["sep_list",]n,string] : Returns the nth field in string. The first field is numbered 0. If n is negative, fields are counted backwards from the end of string. You can specify the rightmost field by setting n to -0.
You can specify a range of fields to return with the syntax:
@FIELD[["sep_list",]start[-end | +range],string]
Specify an inclusive range with a -. For example:
%@FIELD[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:
%@FIELD[2+1,A B C D E F G] will return "C D".
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 double quote as a separator, prefix it with an escape character, e.g., ^". Alphabetic characters in sep_list are case sensitive. If you do not specify a separator list, @FIELD will skip any leading separators.
@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. There is no hexadecimal form to specify field -0 (the rightmost field).
If string is double quoted, you must specify sep_list.
See also: @WORD, @WORDS, @FIELDS.
Examples:
function |
value |
%@field[2,zero,one,two,three] |
two |
%@field[2,zero,,two,three] |
two |
%@field["\",2,C:\Program Files\My Dir\myapp.exe] |
My Dir |
%@field[-2,zero,one,two,three] |
one |