ntharg
含义:Return a formatted list containing fields from a text string.Returns the fields from text that are specified by arguments, treating multiple consecutive delimiters as a single delimiter.(返回在一个字符串中指定的对象)
Format
ntharg(text,arguments,[delimiters],[separator],[line-separator])
Parameters
Parameter | Definition |
text | text to be separated into fields by the ntharg() function The text can be a text string enclosed in double quotation marks,or one or more PSL commands that produce text as output. |
arguments | integer list specifying the field numbers ntharg() should look for in each line of text. Valid Values |
delimiters | one or more optional characters that ntharg() should treat as field separators when examining text Default |
separators | optional character(s) that ntharg() inserts between each field of output Default |
line-separator | optional character(s) that ntharg() uses to replace each new-line character (\n) that appears in text Default Example |
Description
The ntharg() function returns the arguments in text and normally interprets each line in text as a white space-separated(space or tab) list of fields. If delimiters is given,
it specifies the list of characters that ntharg() should treat as field separators. The ntharg() function normally returns selected fields as a new-line delimited list. If separator is given, it specifies the delimiter to be placed between items in the returned list.
Note:
The difference between the ntharg() function and the nthargf() function is as follows:
->The ntharg() function treats each delimiter that follows a non-delimiter character as the end of a field. The ntharg() function interprets two or more adjacent delimiters as a single delimiter, thereby ignoring multiple delimiters and treating them as one.
->The nthargf() function treats each delimiter as the end of a field. The nthargf() function interprets two or more adjacent delimiters as delimiting one or more NULL strings whose content can be requested and returned.
Example
Code:
string="abc::123:xyz";
A=ntharg(string,"3",":");
B=nthargf(string,"3",":");
print("ntharg() 3rd string argument is ",A,"\n");
print("nthargf() 3rd string argument is ",B,"\n");
Output: