Applying an EXCLUDE rule to a base pattern instructs the GLASS engine to exclude a pattern from being reported as a match if it is represented in the selected MAP namespace(s).
The generic GLASS syntax for EXCLUDE is:
<search pattern> EXCLUDE [STRIP|TRIM] <namespace>
ACME Corporation defines a general base pattern to search for 9-digit strings that represent the serial number in the regional customer ID.
RANGE DIGIT TIMES 9
Since DIGIT represents all integers
between 0
to 9
, the GLASS pattern above will
match any 9-digit string from 000000000
to 999999999
.
As 000000000
is not a valid serial number, the
EXCLUDE pattern rule is applied so that
000000000
is excluded as a match.
MAP 'INVALID_SERIAL_NUM' 0
RANGE DIGIT TIMES 9 EXCLUDE 'INVALID_SERIAL_NUM'
The equivalent configuration in GLASS Studio Visual Builder mode is:
If the TRIM modifier is defined, non-alphanumeric characters are removed from the leading and trailing ends of the matched pattern prior to looking up the matched pattern in the EXCLUDE namespace.
If the STRIP modifier is defined, all occurrences of non-alphanumeric characters are removed from the matched pattern (not just leading or trailing characters) prior to looking up the matched pattern in the EXCLUDE namespace.
Non-alphanumeric characters refer to any character outside of the ASCII range of
letters and digits (e.g. ^0-9a-zA-Z
); however this may also depend on the
locale in which the GLASS engine is running.
MAP 'BAD_NUMBERS' 111_111, 666_666, 888_888, 999_999
WORD '<' THEN \
( \
(RANGE DIGIT TIMES 1-6) OR \
(RANGE DIGIT TIMES 1-3 THEN WORD ',' THEN RANGE DIGIT TIMES 3) \
) EXCLUDE STRIP 'BAD_NUMBERS' THEN \
WORD '>'
With the STRIP operator applied to the above GLASS expression, Line 1, Line 2, Line 3 and Line 5 below will be returned as match locations by the GLASS engine:
1 | <0> |
2 | <0,123> |
3 | <444444> |
4 | <111,111> |
5 | <555,555> |
6 | <1000,000> |
Line 4 will not be matched as 111,111
(processed as 111111
after the
STRIP modifier is applied) is present in the
BAD_NUMBERS namespace referenced by the
EXCLUDE rule.
As the GLASS expression will only match up to 6-digit numbers, Line 6 will not be returned as a match location.
See Syntax Overview - Integers for more information.
To add a EXCLUDE rule for a base pattern in GLASS Studio Visual Builder Mode:
Selected namespaces will be added to the Map(s) Selected pane. See MAP Namespace for more information.
To edit an EXCLUDE rule:
To remove an EXCLUDE rule: