Enum

ENUM { string=integer , … }

Enum constructor allows matching for a set of predefined strings and converts them into respectively assigned integer values. The strings and respective integer values are declared as series of key-value pairs, separated by commas and enclosed in curly brackets.

output type:

INTEGER

quantifier:

none

configuration:

cis = true allows matching string values case insensitively. Default false.

locale = string specifying IETF BCP 47 language tag enclosed in single or double quotes (see the list here ). The default locale is English.

charset = character set name enclosed in single or double quotes (for example charset="ISO-8859-1")

Example 23. Suppose we have data with username, login result and comment fields:

Alice;success;all good
Bob;Wrong password;attempts left 2
Oscar;tech error;
Mallory;;doodaloo

Pattern. Line 3 maps login result strings (case-insensitively) to integer values:

1
2
3
4
LD:username ';'
ENUM{''=-3, 'success'=0, 'Wrong password'=1, 'tech error'=2}(cis=true):result ';'
LD*:comment
EOL;

Result:

username result comment _unmatched
Alice 0 all good NULL
Bob 1 attempts left 2 NULL
Oscar 2   NULL
Mallory -3 doodaloo NULL