Regular Expressions 101

Community Library Entry

2

Regular Expression
PCRE (PHP <7.3)

/
(?<type>[A-Z])(?<subtype>[<A-Z])(?<country>\w{3})(?<lname>[A-Z]+)(?<lname2><[A-Z]+){0,}<<(?<fname>[A-Z]+)(?<mname1><[A-Z]+){0,}(?<complement><){0,}\n(?<pnum>[\d\w]{9})(?<pnumcheck>\d{1})(?<nat>\w{3})(?<yob>\d{2})(?<mob>\d{2})(?<dob>\d{2})(?<dobcheck>\d{1})(?<sex>M|F|<{1})(?<yoe>\d{2})(?<moe>\d{2})(?<doe>\d{2})(?<expcheck>\d{1})(?<pid>[\d\w<]{14})(?<pidcheck>\d{1})(?<generalcheck>\d{1})
/
m

Description

Regex to identify and split the components of a machine readable passport pattern text

Submitted by Igor Ferreira - 9 years ago