Regular Expressions 101

Community Library Entry

1

Regular Expression
PCRE2 (PHP >=7.3)

/
^((\d{2}(?!0229))|([02468][048]|[13579][26])(?=0229))(0[1-9]|1[0-2])(0[1-9]|[12]\d|(?<!02)30|(?<!02|4|6|9|11)31)\-(\d{2})\-(\d{4})$
/
gm

Description

Strict Malaysian NRIC format check

Version 2: Shorten with assertion

Submitted by 17Hieng - a year ago (Last modified a year ago)