$token (parse-spec) function
This function returns the value produced by parse-spec as a single word, where the result of the parse-spec value has all spaces substituted with an underscore ( _ ) character. This makes a single-space delimited word out of a series of words. The return value can be useful when using functions such as $delim(), $concat(), and $message(), when a single word output of these functions is required. If the parse-spec returns a single word value, then this function simply passes back the value and performs no other action.
This function can be useful with the CPars-exe command line utility, or for any special cases where a single word is required (as opposed to multiple words), but otherwise has limited use.
The following examples show target strings, parse expressions, and return values:
Target string | Parse expression | Return value |
---|---|---|
This is a test
| $token ($delim(eol, 1)) | This_is_a_test Explanation: The $delim() function parses all words (delimited by the end of line) and adds underscore characters between the values. |
Test - DBID: 100 - OBID: 200 - Test | $token ($concat(dbid: *, obid: *)) | 100_200 Explanation: The $token() function parses dbid and obid values and adds an underscore character between the values. |
My user: Bill xxx | $token (user: *) | Bill Explanation: The $token() function is replaced by the parsed value without modification. |
Related topic