base.StringTokenizer.createExt
Create a string tokenizer object with escape char and null handling.
Syntax
base.StringTokenizer.createExt(
str STRING,
delimiters STRING,
escapeChar STRING,
withNulls BOOLEAN )
RETURNS base.StringTokenizer
- str is the character string to be parsed.
- delimiters defines the delimiters to be used.
- escapeChar defines the character to escape a delimiter.
- withNulls indicates if empty tokens must be returned when there is nothing between delimiters.
Usage
Use the base.StringTokenizer.createExt()
class method to create a string
tokenizer object, with escape character and null token handling.
The created object must be assigned to a program variable defined with the
base.StringTokenizer
type.
The method can take a unique or multiple delimiters into account. A delimiter is always one character long.
When defining an escape character with the third parameter, the delimiters can be escaped in the source string.
When passing TRUE
for the withNulls parameter, empty tokens
are taken into account. The nextToken()
method might return NULL
strings. In the source string, leading and trailing delimiters or the amount of delimiters between
two tokens affects the number of tokens.
Example
DEFINE tok base.StringTokenizer
LET tok = base.StringTokenizer.createExt("|aaa||b\\|bb|ccc","|","\\",TRUE)
For a complete example, see Example 2: Escaped delimiters and NULL tokens.