TOKEN: Extracting a Token From a String

How to:

The TOKEN function extracts a token (substring) based on a token number and a delimiter character.


Top of page

x
Syntax: How to Extract a Token From a String
TOKEN(string, delimiter, number)

where:

string

Fixed length alphanumeric

Is the character string from which to extract the token.

delimiter

Fixed length alphanumeric

Is a single character delimiter.

number

Integer

Is the token number to extract.



Example: Extracting a Token From a String

TOKEN extracts the second token from the PRODUCT_SUBCATEG column, where the delimiter is the letter P:

DEFINE FILE WF_RETAIL_LITE
TOK1/A20 =TOKEN(PRODUCT_SUBCATEG,'P',2);
END
TABLE FILE WF_RETAIL_LITE
SUM TOK1 AS Token
BY PRODUCT_SUBCATEG
ON TABLE SET PAGE NOPAGE
END

The output is:


WebFOCUS