ACME Corporation Customer ID

This example is based on ACME Corporation's customer ID number. See Getting To Know ACME Corporation for more information.

Data Type Requirements

Customer ID Number Format

  • Regional: <ccTLD><9-digit serial number><check digit>

    ACME Corporation Sample Regional Customer ID

  • Worldwide: WW<YYMMDD><5-digit serial number><check digit>

    ACME Corporation Sample Worldwide Customer ID

Breakdown of Components in Customer ID Number

Component Description Valid Values
ccTLD Country code top-level domain. AU, IE, KR, SG, UK, US.
serial number A 9-digit (regional) or 5-digit (worldwide) serial number that starts at 1. The first serial number for the regional and worldwide s are 000000001 and 00001 respectively. Regional: 000000001 to 999999999, Worldwide: 00001 to 99999.
check digit A single check digit that is computed from all the other characters in the number using the check digit algorithm adopted for use in Machine Readable Travel Documents (MRTDs). See Section 4.9: ICAO Doc 9303 - Machine Readable Travel Documents for more information. Single integer between 0 to 9.
YYMMDD A valid short date representing the expiration date of the , where
- YY is the 2-digit year between 00 to 99,
- MM is the 2-digit month between 01 to 12, and
- DD is the 2-digit date between 01 - 31.
Any date between 1901-01-01 and 2099-12-31.

Boundary Rules

ACME Corporation expects a customer ID number to only be bounded by non-alphanumeric characters on either side to be valid.

ACME Corporation Customer ID Boundary Condition

Contextual Keywords

ACME Corporation identified a set of words (in various supported languages) that can commonly be found within a certain range before a customer ID number. These are known as contextual keywords.

  • In English: cust id, custid, customer
  • In English and French: client
  • In French: cliente
  • In German: kunde
  • In Korean: 고객

Customer ID Number Samples

Some valid samples of customer ID numbers:

Category Customer ID Sample
Regional AU2648761235, IE4871209841, KR8837000014, SG0000137492, UK0027738122, US1003992835
Worldwide WW301231018313, WW410425001348

Some invalid samples of customer ID numbers:

Category Customer ID Sample Notes
Regional ZZ7366198321 Invalid ccTLD prefix (ZZ)
Regional US0000000004 Invalid serial number (000000000)
Regional AU7366198329 Invalid check digit (9)
Worldwide ZZ301231018313 Invalid prefix (ZZ)
Worldwide WW301231000002 Invalid serial number (00000)
Worldwide WW300229018317 Invalid short date (300229)
Worldwide WW301231018311 Invalid check digit (1)
Go through the detailed steps to build out the custom GLASS data type (recommended), or jump straight to the recommended GLASS solution.

Part 1 - ccTLD in Regional Customer ID

In Part 1, we start by creating a namespace (MAP NOCASE 'ACME_CUST_ID_CCTLD') containing all valid ccTLD values and reference it using the GROUP operator.

MAP NOCASE 'ACME_CUST_ID_CCTLD' 'AU', 'IE', 'KR', 'SG', 'UK', 'US'

GROUP 'ACME_CUST_ID_CCTLD'

See MAP and GROUP for more information.

Part 2 - 9-digit Serial Number in Regional Customer ID

In Part 2, we define the expression that will match the 9-digit serial number in a 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, it is added to a namespace ((MAP 'INVALID_SERIAL_NUM') and referenced by the EXCLUDE pattern rule so that 000000000 is excluded as a match.

MAP 'INVALID_SERIAL_NUM' 0

RANGE DIGIT TIMES 9 EXCLUDE 'INVALID_SERIAL_NUM'

See MAP, RANGE, Preset Keywords, EXCLUDE and GLASS Grammar - Integers for more information.

Part 3 - Single Check Digit in Regional Customer ID

In Part 3, we define the expression that will match the check digit in a regional customer ID.

RANGE DIGIT

Part 4 - Putting the Regional Customer ID Together

In Part 4, we join the expressions (THEN) from Part 1 to Part 3 to form the complete base pattern for ACME Corporation's regional customer ID.

MAP 'INVALID_SERIAL_NUM' 0
MAP NOCASE 'ACME_CUST_ID_CCTLD' 'AU', 'IE', 'KR', 'SG', 'UK', 'US'

GROUP 'ACME_CUST_ID_CCTLD' THEN \
(RANGE DIGIT TIMES 9 EXCLUDE 'INVALID_SERIAL_NUM') THEN \
RANGE DIGIT

See THEN and OR for more information.

Part 5 - Boundary Rule and Checksum Validation for Regional Customer ID

In Part 5, we define the pattern boundaries (BOUND NONALNUM) and include the checksum validation (CHECK 'PASSPORTMOD10') for the regional customer ID.

MAP 'INVALID_SERIAL_NUM' 0
MAP NOCASE 'ACME_CUST_ID_CCTLD' 'AU', 'IE', 'KR', 'SG', 'UK', 'US'

( \
  GROUP 'ACME_CUST_ID_CCTLD' THEN \
  (RANGE DIGIT TIMES 9 EXCLUDE 'INVALID_SERIAL_NUM') THEN \
  RANGE DIGIT \
) CHECK 'PASSPORTMOD10' BOUND NONALNUM

The custom GLASS expression in Part 5 addresses all the requirements to search for ACME Corporation's regional customer ID.

See CHECK, Supported Check Modules and BOUND for more information.

Part 6 - Prefix in Worldwide Customer ID

In Part 6, we search (case-insensitively) for the WW prefix in the worldwide customer ID (WORD NOCASE 'ww').

WORD NOCASE 'ww'

See WORD for more information.

Part 7 - Short Date in Worldwide Customer ID

In Part 7, we define the expression to match the short date component (YYMMDD) in a worldwide customer ID.

  1. YY is any two digits between 00 to 99.
    RANGE DIGIT TIMES 2
    
  2. MM is any valid month between 01 to 12. For this, we use the RANGE operator to search for 2 consecutive ASCII digits but limit the matches to specific values in a REQUIRE namespace.
    MAP 'MONTH_OF_YEAR_LOOKUP' 1-12
    
    RANGE DIGIT TIMES 2 REQUIRE 'MONTH_OF_YEAR_LOOKUP'
    
  3. DD is any valid month between 01 to 31. For this, we use the RANGE operator to search for 2 consecutive ASCII digits but limit the matches to specific values in a REQUIRE namespace.
    MAP 'DAY_OF_MONTH_LOOKUP' 1-31
    
    RANGE DIGIT TIMES 2 REQUIRE 'DAY_OF_MONTH_LOOKUP'
    

The three parts are joined together using the THEN connector, and the VALID_DATE_YYMMDD checksum module is applied to verify that the 6-digit pattern is a valid date between 1901-01-01 to 2099-12-31.

MAP 'MONTH_OF_YEAR_LOOKUP' 1-12
MAP 'DAY_OF_MONTH_LOOKUP' 1-31

( \
  RANGE DIGIT TIMES 2 THEN \
  (RANGE DIGIT TIMES 2 REQUIRE 'MONTH_OF_YEAR_LOOKUP') THEN \
  (RANGE DIGIT TIMES 2 REQUIRE 'DAY_OF_MONTH_LOOKUP') \
) CHECK 'VALID_DATE_YYMMDD'

See MAP, RANGE, REQUIRE, THEN and OR, CHECK, and Supported Check Modules for more information.

Part 8 - 5-digit Serial Number in Worldwide Customer ID

In Part 8, we take the same approach as Part 2 where we use the RANGE operator to search for five consecutive digits but EXCLUDE 00000 as a match.

MAP 'INVALID_SERIAL_NUM' 0

RANGE DIGIT TIMES 5 EXCLUDE 'INVALID_SERIAL_NUM'

Part 9 - Single Check Digit in Worldwide Customer ID

In Part 9, we define the expression that will match the check digit in a regional customer ID.

RANGE DIGIT

Part 10 - Putting the Worldwide Customer ID Together

In Part 10, we take the same approach as Part 4 and join the expressions (THEN) from Part 6 to Part 9 to form the complete base pattern for ACME Corporation's worldwide customer ID.

MAP 'MONTH_OF_YEAR_LOOKUP' 1-12
MAP 'DAY_OF_MONTH_LOOKUP' 1-31
MAP 'INVALID_SERIAL_NUM' 0

WORD NOCASE 'ww' THEN \
( \
  RANGE DIGIT TIMES 2 THEN \
  (RANGE DIGIT TIMES 2 REQUIRE 'MONTH_OF_YEAR_LOOKUP') THEN \
  (RANGE DIGIT TIMES 2 REQUIRE 'DAY_OF_MONTH_LOOKUP') \
) CHECK 'VALID_DATE_YYMMDD' THEN \
(RANGE DIGIT TIMES 5 EXCLUDE 'INVALID_SERIAL_NUM') THEN \
RANGE DIGIT

Part 11 - Boundary Rule and Checksum Validation for Worldwide Customer ID

In Part 11, we define the pattern boundaries (BOUND NONALNUM) and include the checksum validation (CHECK 'PASSPORTMOD10') for the worldwide customer ID.

MAP 'MONTH_OF_YEAR_LOOKUP' 1-12
MAP 'DAY_OF_MONTH_LOOKUP' 1-31
MAP 'INVALID_SERIAL_NUM' 0

( \
  WORD NOCASE 'ww' THEN \
  ( \
    RANGE DIGIT TIMES 2 THEN \
    (RANGE DIGIT TIMES 2 REQUIRE 'MONTH_OF_YEAR_LOOKUP') THEN \
    (RANGE DIGIT TIMES 2 REQUIRE 'DAY_OF_MONTH_LOOKUP') \
  ) CHECK 'VALID_DATE_YYMMDD' THEN \
  (RANGE DIGIT TIMES 5 EXCLUDE 'INVALID_SERIAL_NUM') THEN \
  RANGE DIGIT \
) CHECK 'PASSPORTMOD10' BOUND NONALNUM

The custom GLASS expression in Part 11 addresses all the requirements to search for ACME Corporation's worldwide customer ID.

Part 12 - Combining the Expressions for the Regional and Worldwide Customer ID

As ACME Corporation does not require the matches for the regional or worldwide customer ID to be differentiated as a different data type, the expressions from Part 5 and Part 11 can be joined using the OR operator.

1 MAP 'INVALID_SERIAL_NUM' 0
2 MAP 'MONTH_OF_YEAR_LOOKUP' 1-12
3 MAP 'DAY_OF_MONTH_LOOKUP' 1-31
4 MAP NOCASE 'ACME_CUST_ID_CCTLD' 'AU', 'IE', 'KR', 'SG', 'UK', 'US'
5  
6 ( \
7   ( \
8     ( \
9       GROUP 'ACME_CUST_ID_CCTLD' THEN \
10       (RANGE DIGIT TIMES 9 EXCLUDE 'INVALID_SERIAL_NUM') THEN \
11       RANGE DIGIT \
12     ) CHECK 'PASSPORTMOD10' \
13   ) \
14   OR \
15   ( \
16     ( \
17       WORD NOCASE 'ww' THEN \
18       ( \
19         RANGE DIGIT TIMES 2 THEN \
20         (RANGE DIGIT TIMES 2 REQUIRE 'MONTH_OF_YEAR_LOOKUP') THEN \
21         (RANGE DIGIT TIMES 2 REQUIRE 'DAY_OF_MONTH_LOOKUP') \
22       ) CHECK 'VALID_DATE_YYMMDD' THEN \
23       (RANGE DIGIT TIMES 5 EXCLUDE 'INVALID_SERIAL_NUM') THEN \
24       RANGE DIGIT \
25     ) CHECK 'PASSPORTMOD10' \
26   ) \
27 ) BOUND NONALNUM

The parentheses () on line 6 and line 27 are added to

  1. Group the expressions for the (i) regional customer ID and (ii) worldwide customer ID into a single logical statement, and
  2. To enable the BOUND rule to be applied to the whole expression within the parentheses.

See THEN and OR for more information.

Part 13 - Context Space for Customer ID

To improve the pattern matching accuracy of the customer ID data type in Part 12, we can declare a set of contextual keywords (CONTEXT and APPLY) and require (REQUIRE) these keywords to be present before (BEFORE) a potential customer ID number for it to be reported as a match.

MAP 'INVALID_SERIAL_NUM' 0
MAP 'MONTH_OF_YEAR_LOOKUP' 1-12
MAP 'DAY_OF_MONTH_LOOKUP' 1-31
MAP NOCASE 'ACME_CUST_ID_CCTLD' 'AU', 'IE', 'KR', 'SG', 'UK', 'US'
MAP NOCASE 'ACME_CUST_ID_CONTEXTS' 'cust id', 'custid', 'customer', 'client', 'cliente', 'kunde', '고객'

CONTEXT 'ACME_CUST_ID_CONTEXT' BEFORE REQUIRE 'ACME_CUST_ID_CONTEXTS'

( \
  ( \
    ( \ # Expression for regional customer ID
      ( \
        GROUP 'ACME_CUST_ID_CCTLD' THEN \
        (RANGE DIGIT TIMES 9 EXCLUDE 'INVALID_SERIAL_NUM') THEN \
        RANGE DIGIT \
      ) CHECK 'PASSPORTMOD10' \
    ) \
    OR \
    ( \ # Expression for worldwide customer ID
      ( \
        WORD NOCASE 'ww' THEN \
        ( \
          RANGE DIGIT TIMES 2 THEN \
          (RANGE DIGIT TIMES 2 REQUIRE 'MONTH_OF_YEAR_LOOKUP') THEN \
          (RANGE DIGIT TIMES 2 REQUIRE 'DAY_OF_MONTH_LOOKUP') \
        ) CHECK 'VALID_DATE_YYMMDD' THEN \
        (RANGE DIGIT TIMES 5 EXCLUDE 'INVALID_SERIAL_NUM') THEN \
        RANGE DIGIT \
      ) CHECK 'PASSPORTMOD10' \
    ) \
  ) BOUND NONALNUM \
) APPLY 'ACME_CUST_ID_CONTEXT'

See CONTEXT and APPLY for more information.

Match Samples

Based on the GLASS expression in Part 13 - Context Space for Customer ID, the regional and worldwide customer IDs underlined in line 1, line 2 and line 4 (and line 3) will be returned as matches by the GLASS pattern matching engine.

1
2
3
4
5
6
고객 KR1014562499...
Customer ID: WW100615094321
Client_ details
SG0000137492,customer_email@example.com,Platinum Level
My worldwide ID number is WW201123545540
custid , AU1122334459

The worldwide customer ID in line 5 will not be marked as a match as there are no contextual keywords within 64-bytes before the potential match.

The pattern on line 6 will not be marked as a match as it fails the checksum validation on the last digit of the regional customer ID.