One or more expressions can form a rule that determines whether the input data matches or not. Whenever a rule generates a match, the engine will report this match.
When this reporting happens, it is helpful to identify what rule has matched. This can be done with the LABEL operator.
The generic GLASS syntax for LABEL is:
LABEL '<literal>'
<expressions>
A LABEL operator is in effect until another LABEL operator is encountered. By default, if no LABEL operator has been used, matched rules will be reported as 'No label' matches.
MAP NOCASE 'Marvel_List' 'Captain America', 'Iron Man', 'Ant Man', 'Black Widow'
MAP NOCASE 'DC_List' 'Batman', 'Superman', 'Shazam', 'Aquaman'
LABEL 'Marvel Superheroes'
GROUP 'Marvel_List'
LABEL 'DC Superheroes'
GROUP 'DC_List'
In the example above, matches for any key in the Marvel_List namespace will be identified as Marvel Superheroes matches, while matches for any key in the DC_List namespace will be reported under the label / identifier DC Superheroes.
If we take a look at the example GLASS code in [DECLARE and CALL Example 1], we can add the LABEL operator to more easily identify the matches according to the card issuing network.
MAP 'CHD_BIN_DINERSCLUBINT' 3600_0000_0000_0000-3699_9999_9999_9999
MAP 'CHD_BIN_MASTERCARD' 5100_0000_0000_0000-5599_9999_9999_9999
MAP 'CHD_BIN_VISA' 4000_0000_0000_0000-4999_9999_9999_9999
DECLARE 'CHD_4_GROUP_SEPARATOR_TEMPLATE', \
${chd_network}, ${separator_label}, ${separator_character} {
ALIAS 'CHD_${chd_network}_16DIGIT_SEPARATOR_${separator_label}' \
( \
RANGE DIGIT TIMES 4 THEN WORD '${separator_character}' THEN \
RANGE DIGIT TIMES 4 THEN WORD '${separator_character}' THEN \
RANGE DIGIT TIMES 4 THEN WORD '${separator_character}' THEN \
RANGE DIGIT TIMES 4 \
) REQUIRE STRIP 'CHD_BIN_${chd_network}' BOUND NONALNUM CHECK 'LUHNCHKSUM'
REFER 'CHD_${chd_network}_16DIGIT_SEPARATOR_${separator_label}'
}
LABEL 'Diners Club'
CALL 'CHD_4_GROUP_SEPARATOR_TEMPLATE', 'DINERSCLUBINT', 'HYPHEN', '-'
CALL 'CHD_4_GROUP_SEPARATOR_TEMPLATE', 'DINERSCLUBINT', 'SPACE', ' '
LABEL 'Mastercard'
CALL 'CHD_4_GROUP_SEPARATOR_TEMPLATE', 'MASTERCARD', 'HYPHEN', '-'
CALL 'CHD_4_GROUP_SEPARATOR_TEMPLATE', 'MASTERCARD', 'SPACE', ' '
LABEL 'Visa'
CALL 'CHD_4_GROUP_SEPARATOR_TEMPLATE', 'VISA', 'HYPHEN', '-'
CALL 'CHD_4_GROUP_SEPARATOR_TEMPLATE', 'VISA', 'SPACE', ' '