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.
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>'
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:
An octet is a digital unit that represents a sequence of 8 bits. For
example, the octet value
00110000
represents
the ASCII digit
0
.
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'
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
-
, andA
to H
(e.g. A
, B
, C
, …, G
,
H
).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.
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.
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:
1
, 3
, 7
, or 9
.
RANGE '1379'
:
, whitespace
, or comma ,
character.
RANGE ' :,'
,
) when specifying the
list of characters to match in a RANGE search
pattern.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:
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.
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 |
:
, whitespace
, comma ,
),
use the BOUND operator.The equivalent configuration in GLASS Studio Visual Builder mode is:
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.
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>]
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:
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:
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.
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 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:
You can define the following pattern rules for the RANGE data pattern:
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.
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.
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.
To search for a specific data pattern using the RANGE operator in GLASS Studio Visual Builder Mode:
To edit the RANGE component:
To duplicate the RANGE component:
See Duplicating a Component for more information.
To remove the RANGE component along with the corresponding GLASS code:
To change from RANGE to another base pattern:
Click on RANGE at the top bar and select a different
base pattern.