Logo Wand.Tools

Regular Expression Generator

Intelligently generate and explain regular expressions, supporting various common pattern matching

Comprehensive Tutorial on Regular Expressions for Global ID Card (ID Card) Number Matching

  # Comprehensive Tutorial on Regular Expressions for Global ID Card (ID Card) Number Matching
  
  In the formats of ID Numbers across different countries globally, the structure varies. This tutorial compiles regular expression matching rules for ID cards of many countries, applicable to scenarios like form validation, data scraping, user information processing, etc., helping developers quickly and accurately identify ID card number formats from various countries.
  
  ---
  
  ## 🧩 Mainland China (PRC)
  
  ```regex
  ^\d{6}(18|19|20)?\d{2}(0[1-9]|1[0-2])(0[1-9]|[12]\d|3[01])\d{3}[\dXx]$
  • Supports 15-digit and 18-digit ID cards.
  • Date format (year-month-day), checksum supports uppercase X and lowercase x.

🇭🇰 Hong Kong (HKID)

^[A-Z]{1,2}\d{6}\([0-9A]\)$
  • Letter prefix + 6 digits + bracketed checksum.
  • Checksum can be a digit or “A”.

🇲🇴 Macau (Macau Resident ID)

^[157][0-9]{6}\([0-9]\)$
  • Starts with 1, 5, or 7 + 6 digits + checksum.

🇹🇼 Taiwan (TWID)

^[A-Z][12]\d{8}$
  • First character is an uppercase letter + 1 or 2 (gender) + 8 digits.

🇺🇸 United States (SSN)

^\d{3}-\d{2}-\d{4}$
  • Social Security Number format, typically used for identification.

🇬🇧 United Kingdom (NINO)

^[A-CEGHJ-PR-TW-Z]{2}\d{6}[A-D]$
  • 2-letter prefix (cannot contain D, F, I, Q, U, V) + 6 digits + ending letter (A-D).

🇯🇵 Japan (My Number)

^\d{12}$
  • Japan’s “Individual Number”, fixed 12 pure digits.

🇰🇷 South Korea (RRN)

^\d{6}-[1-4]\d{6}$
  • Date of birth + gender/century code + serial number.

🇸🇬 Singapore (NRIC/FIN)

^[STFG]\d{7}[A-Z]$
  • 1 uppercase letter (S/T/F/G) + 7 digits + checksum letter.

🇲🇾 Malaysia (MyKad)

^\d{6}-\d{2}-\d{4}$
  • Date of birth + state code + serial number.

🇮🇳 India (Aadhaar)

^\d{4}\s\d{4}\s\d{4}$
  • 12 digits, separated into 3 blocks by spaces.

🇨🇦 Canada (SIN)

^\d{3}-\d{3}-\d{3}$
  • Social Insurance Number, 9 digits, common format is xxx-xxx-xxx.

🇦🇺 Australia (Medicare)

^\d{4}\s\d{5}\s\d{1}$
  • Common Medicare card number format, 4+5+1 digit combination.

🔐 Multi-Country Wildcard Validation (Common IDs)

^[A-Z0-9\-\(\)\s]{5,20}$
  • For compatibility validation: 5 to 20 characters, composed of uppercase letters, numbers, parentheses, hyphens, or spaces.

Global ID Card Regular Expressions, ID Card Format Guide, ID Number Validation Rules, ID Card Regex Patterns, Regex for National ID Numbers, Complete Guide to ID Card Number Regular Expressions, International ID Card Format Matching, ID Recognition Regex, Validation of ID Cards from Various Countries, Regex ID Number Validation Table


📌 Disclaimer

The above regular expressions are for basic format validation only. In actual scenarios, please combine them with the legality validation rules of each country’s ID cards (such as Luhn algorithm, date of birth validity, etc.) to ensure completeness.