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
  1. str is the character string to be parsed.
  2. delimiters defines the delimiters to be used.
  3. escapeChar defines the character to escape a delimiter.
  4. 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.

Note: To specify a backslash as a delimiter, you must use double backslashes in both the source string and as the delimiter, as shown in Example 3: Specify a backslash as a delimiter

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.