RANGE Operator

Overview of the RANGE Operator

Use the RANGE operator to search for N number (TIMES) of characters from a specific set of characters. A location will be marked as a match if N characters from the defined range are found in the location.

GLASS Studio RANGE Component

Defining a RANGE

Using the RANGE operator, you can search for one or more characters specified in the preset or custom set of characters.

The generic GLASS syntax for RANGE is:

RANGE '<range of characters>'

Inclusive Range of Characters

Using the hyphen - character anywhere in the <range of characters> - except at the beginning and/or the end - defines an inclusive range of values to search for.

RANGE '<v1>-<v2>'

where:

  • <v1> is the lower boundary of the range of values (or literal range),
  • <v2> is the upper boundary of the range of values, and
  • The range of values is defined as
    • Any octet between the two boundaries (for non-Unicode values), or
    • Any Unicode scalar values between the two boundaries (for Unicode values).
What is an "octet"?

An octet is a digital unit that represents a sequence of 8 bits. For example, the octet value 00110000 represents the ASCII digit 0.

RANGE Example 1

The equivalent GLASS code to search for a single digit between 0 to 9 (e.g. 0, 1, 2, …, 8, 9) is:

RANGE '0-9'

RANGE Example 2

1 RANGE 'A-H'
2 RANGE '-A-H'

The GLASS code in Line 1 searches for any uppercase character between A to H (e.g. A, B, C, …, G, H).

For Line 2, the GLASS pattern matching engine searches for

  • The hyphen character -, and
  • Any uppercase character between A to H (e.g. A, B, C, …, G, H).

Searching for a Preset RANGE

The GLASS reference language supports a list of predefined keywords that represent commonly used literal ranges. These preset keywords may be used in place of the literal ranges that they represent when defining a RANGE search pattern.

GLASS Studio RANGE Component - Preset

For example, the expressions on Line 1 and Line 2 are equivalent. Both expressions instruct the GLASS pattern matching engine to search for and match any ASCII digit from 0 to 9.

1 RANGE '0-9'
2 RANGE DIGIT

See the Preset Keywords for more information.

Searching for a Custom RANGE

You can specify a custom set of characters when defining a RANGE search pattern by clicking on Customized in the RANGE section of the base pattern form.

For example, search for:

  • The digit 1, 3, 7, or 9.
    RANGE '1379'
    
  • A colon :, whitespace  , or comma , character.
    RANGE ' :,'
    

GLASS Studio RANGE Component - Customized

RANGE Example 3

Suppose you are tasked to search for all Singapore National Registration Identity Card (NRIC) numbers or Foreign Identification Number (FIN)s in your organization's storage locations. One approach when defining the data type is to match 9-character strings only if the first character (which denotes the status of the NRIC/FIN holder) is from a specific character set (e.g. S, T, F, G, M).

RANGE 'STFGM'

Using the custom GLASS expression above, all the following lines will be returned as match locations by the GLASS pattern matching engine:

1 S1234567D
2 G1234567X
3 T1234567J

The equivalent configuration in GLASS Studio Visual Builder mode is:

  • Data type component: RANGE
    • Data pattern to search for (Customized): STFGM

Matching a RANGE

Matches are not limited by traditional word boundaries (e.g. whitespaces, new lines) and can happen anywhere in a string or data stream, unless pattern boundaries are defined.

RANGE Example 4

You write a simple GLASS expression to search for the characters S, T, F, G, or M:

RANGE 'STFGM'

As no pattern boundaries are defined, all the following lines will be returned as match locations by the GLASS pattern matching engine:

1 NRIC: S1234567D
2 AG1234567X
3 1T1234567J

The equivalent configuration in GLASS Studio Visual Builder mode is:

  • Data type component: RANGE
    • Data pattern to search for: ID

Repeated Characters in a RANGE

The TIMES option instructs the GLASS pattern matching engine to return the location as a match if the search characters (octets) defined in the RANGE appear a specified number of times.

GLASS Studio RANGE Component - Repeats

By default, if the TIMES option is not defined, this implicitly sets the TIMES value to 1.

The generic GLASS syntax for RANGE with the TIMES option is:

RANGE '<range of characters>' TIMES <integer>[-<integer>]

RANGE Example 5

ACME Corporation defines part of the GLASS pattern that matches the 9-digit serial number within a regional customer ID:

RANGE DIGIT TIMES 9

Based on the above GLASS expression, any occurrence of 9 consecutive digits that fall within the range of 000000000 to 999999999 will be returned as match locations by the GLASS pattern matching engine:

1 AU2648761235
2 IE4871209841
3 KR8837000014

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

RANGE Example 6

Using the RANGE and TIMES operator, you write a GLASS expression to detect valid China Union Pay card numbers that can be 16 to 19 digits in length:

RANGE '0-9' TIMES 16-19

All the following lines will be returned as match locations by the GLASS pattern matching engine :

1 6243030000000001
2 8171999900000000021

The equivalent configuration in GLASS Studio Visual Builder mode is:

  • Data type component: RANGE
    • Data pattern to search for (Customized): 0-9
    • Repeat Character/Octet (TIMES) option: Checked, 16 to 19 times

Case Sensitivity of a RANGE

The NOCASE (No Case) option determines if the GLASS pattern matching engine treats uppercase and lowercase characters as distinct (case sensitive) or equal (case-insensitive) characters. This option is only applicable when searching for a custom RANGE in GLASS Studio Visual Builder mode.

GLASS Studio WORD Component Case Sensitivity option

By default, GLASS patterns are case sensitive. This means uppercase and lowercase characters are distinct characters. For example, lowercase a and uppercase A are treated as different characters by the GLASS pattern matching engine.

The GLASS syntax to define a case-sensitive RANGE is:

RANGE '<custom range of characters>'

If the NOCASE (No Case) option is specified or checked in GLASS Studio Visual Builder mode, uppercase and lowercase characters are equal. For example, lowercase a and uppercase A are treated as the same character by the GLASS pattern matching engine.

The GLASS syntax to define a case-insensitive RANGE is:

RANGE NOCASE '<custom range of characters>'

RANGE Example 7

RANGE NOCASE 'STFGM'

Using the GLASS expression in Example 7, all the following lines will be returned as match locations by the GLASS pattern matching engine:

1 S1234567C
2 g1234567M
3 t1234567Z

The equivalent configuration in GLASS Studio Visual Builder mode is:

  • Data type component: RANGE
    • Data pattern to search for (Customized): STFGM
    • No Case (NOCASE) option: Checked

Pattern Rules for a RANGE

You can define the following pattern rules for the RANGE data pattern:

  1. TIMES
  2. BOUND
  3. REQUIRE
  4. EXCLUDE

GLASS Studio Define Pattern Rules for RANGE Component

Boundary Rules for a RANGE

The BOUND precision rule lets you define the list possible characters that the must be found before (BOUND LEFT), after (BOUND RIGHT), or surrounding (BOUND) any data pattern within a RANGE for it to be a match.

See BOUND Rule for more information.

REQUIRE Rule for a RANGE

Applying a REQUIRE rule to a base pattern instructs the GLASS engine to report a match only if the base pattern is explicitly represented in the selected MAP namespace(s).

See REQUIRE Rule for more information.

EXCLUDE Rule for a RANGE

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

See EXCLUDE Rule for more information.

Adding a RANGE Component

To search for a specific data pattern using the RANGE operator in GLASS Studio Visual Builder Mode:

  1. Add a RANGE component to the GLASS Studio project.
  2. Define a preset or custom range.
  3. (Optional) In the Add Pattern Rules pane, click on Times (TIMES) to instruct the GLASS pattern matching engine to return the location as a match if the search characters appear a certain number of times. See Repeated Characters in a RANGE for more information.
  4. (Optional) Select the No Case (NOCASE) option to instruct the GLASS pattern matching engine to treat uppercase and lowercase characters as distinct characters. See Case Sensitivity of a RANGE for more information.
  5. (Optional) Specify additional criteria that must be fulfilled for the search pattern to be returned as a match. See Pattern Rules for a RANGE for more information.

Managing the RANGE Component

To edit the RANGE component:

  1. Left click anywhere in the component to open the base pattern form.
  2. Edit the preset or customized character set, options, or pattern rules, and click Close.

To duplicate the RANGE component:

  1. Right click anywhere in the component to open the context menu and click on Copy.
  2. Go to the component which you want to join the duplicated RANGE component to.
  3. Right click anywhere in the component to open the context menu and click on:
    • Paste > As Then to join connect the duplicated component in series.
    • Paste > As Or to join connect the duplicated component in parallel.

See Duplicating a Component for more information.

To remove the RANGE component along with the corresponding GLASS code:

  1. Right click anywhere in the component to open the context menu and click on Delete, or
    Left click anywhere in the component to open the base pattern form and click on Delete.
  2. In the dialog box, click Delete to confirm the deletion, or click Cancel to cancel the operation. This action can be undone by clicking on the GLASS Studio main menu button > Undo.

To change from RANGE to another base pattern:

  1. Left click anywhere in the component to open the base pattern form.
  2. Click on RANGE at the top bar and select a different base pattern.
    GLASS Studio Change RANGE Base Pattern