RegEx Examples: ICCID, IMEA, and ABN without mod-89 check

This following code finds Australian Business Numbers (ABNs) without a modulus-89 check.

An Australian Business Number (ABN) is a unique 11-digit identifier used to identify businesses to the government, suppliers, and the public. It consists of a 9-digit identifier plus 2 leading check digits. The "mod-89 check" is an algorithm that verifies that the two leading digits are correctly derived from the following nine digits. This validates if an ABN is correctly structured, helping to identify common data entry errors like digit transposition.

Regex (using the pipe '|' character as an OR between conditions):

pData->data =
    _T("(?i)"
       "(?:"
       "\\bICCID\\b[^\\r\\n]*?(?<!\\d)89\\d{17,18}(?!\\d)"
       "|(?<!\\d)89\\d{17,18}(?!\\d)[^\\r\\n]*?\\bICCID\\b"
       "|\\b(?:IMEA|IMEI|SIM)\\b[^\\r\\n]*?(?<!\\d)\\d{15}(?:\\d{2})?(?!\\d)"
       "|(?<!\\d)\\d{15}(?:\\d{2})?(?!\\d)[^\\r\\n]*?\\b(?:IMEA|IMEI|SIM)\\b"
       "|\\bABN\\b[^\\r\\n]*?(?<!\\d)[1-9]\\d\\s?\\d{3}\\s?\\d{3}\\s?\\d{3}(?!\\d)"
       "|(?<!\\d)[1-9]\\d\\s?\\d{3}\\s?\\d{3}\\s?\\d{3}(?!\\d)[^\\r\\n]*?\\bABN\\b"
       ")");

In simple terms:

  • (?i) – Make everything case-insensitive.
    • The terms abn, ABN, Imei, etc. all match
  • The big (?: ... ) group is just a list of OR conditions.
    It’s looking for three types of IDs, each tied to the right label on the same line:
    1. ICCID
      • Looks for the word ICCID and a number that:
        • Starts with 89
        • Has 17 or 18 more digits after that (so 19–20 digits total).
      • ICCID can be before or after the number.
      • It allows any characters between them on that line (spaces, punctuation, etc.).
      • It makes sure the number is not part of a longer digit string.
    2. IMEA / IMEI / SIM
      • Looks for one of the labels IMEA, IMEI, or SIM and a number that is:
        • 15 digits, optionally followed by 2 more digits (so 15 or 17 digits total).
      • Again, the label can be before or after the number on the same line.
      • Ensures the number isn’t embedded inside a bigger run of digits.
    3. ABN (Australian Business Number)
      • Looks for the word ABN and an 11-digit number that:
        • Starts with a digit from 1–9 (no leading 0).
        • May be formatted with optional spaces like 53 004 085 617.
      • ABN can be before or after the number on the same line.
      • Also makes sure the ABN number isn’t part of a longer digit string.
  • [^\r\n]*? – “Any characters on the same line” between the label and the number.
  • (?<!\d) / (?!\d) – “The thing we matched isn’t glued to extra digits on either side.”


Was this article helpful?