EXCLUDE Rule

Overview of the EXCLUDE Rule

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).

GLASS Studio EXCLUDE Rule

The generic GLASS syntax for EXCLUDE is:

<search pattern> EXCLUDE [STRIP|TRIM] <namespace>

EXCLUDE Example 1

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:

  • Data type component: RANGE
    • Data pattern to search for (Select a keyword): DIGIT
    • Repeat Character/Octet (TIMES) option: Checked, 9 times
    • Exclude (EXCLUDE) rule:
      • MAP Label: INVALID_SERIAL_NUM
      • MAP Entries: 0

TRIM and STRIP Modifiers

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.

EXCLUDE Example 2

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.

Adding EXCLUDE Rules

To add a EXCLUDE rule for a base pattern in GLASS Studio Visual Builder Mode:

  1. Add and define the data pattern for a RANGE component.
  2. In the Add Pattern Rules pane, click on Exclude.
    GLASS Studio Add EXCLUDE RuleGLASS Studio Add EXCLUDE Rule Pane
  3. Define the namespace(s) to be referenced by the EXCLUDE operator by:
    • Clicking on Create Map and selecting the newly added MAP namespace, or
    • Selecting an existing MAP namespace from the Select Map(s) pane.

    Selected namespaces will be added to the Map(s) Selected pane. See MAP Namespace for more information.

  4. (Optional) Click to remove a selected MAP namespace from the EXCLUDE rule.
  5. (Optional) Select the TRIM (TRIM) or STRIP (STRIP) option to remove non-alphanumeric characters from the matched pattern prior to looking it up in the selected namespace(s). See TRIM and STRIP Modifiers for more information.

Managing EXCLUDE Rules

To edit an EXCLUDE rule:

  1. Left click anywhere in the component to open the base pattern form.
  2. Click on the Down icon next to the EXCLUDE panel.
  3. Add or remove namespaces, and click Close.

To remove an EXCLUDE rule:

  1. Left click anywhere in the component to open the base pattern form.
  2. Click on the Trash icon next to the EXCLUDE panel.
    GLASS Studio Delete EXCLUDE Rule