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 | quantifier | configuration |
---|---|---|
integer | none | 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 |
Example 23.
Suppose we have data with username, login result and comment fields:
1Alice;success;all good2Bob;Wrong password;attempts left 23Oscar;tech error;4Mallory;;doodaloo
Pattern. Line 3 maps login result strings (case-insensitively) to integer values:
1LD:username ';'2ENUM{''=-3, 'success'=0, 'Wrong password'=1, 'tech error'=2}(cis=true):result ';'3LD*:comment4EOL;
Result:
username | result | comment |
---|---|---|
Alice | 0 | all good |
Bob | 1 | attempts left 2 |
Oscar | 2 | |
Mallory | -3 | doodaloo |