6.1.3 Sample regular expressions
Name |
Description |
Regular Expression |
|
The regex matches on any email. For example: |
(?:^|\s)[\w!#$%& '*+/=?^`{|}~-](\.?[\w!#$%&' *+/=?^`{|}~-]+)*@\w+[.-]?\w*\.[a-zA-Z]{ 2 , 3 }\b |
The regex matches on email with a specific domain. For example: |
(?:^|\s)[\w!#$%& '*+/=?^`{|}~-](\.?[\w!#$%&' *+/=?^`{|}~-]+)* @company .com |
|
U.S. Phone Number |
The regex matches on a U.S. Phone number. For example:
|
(?:(?:\+? 1 [-.\s])?\(?\d{ 3 }\)?[-.\s])?\d{ 3 }[-.\s]\d{ 4 }(?:\s(?:x|#|[eE]xt[.]?|[eE]xtension){ 1 } ?\d{ 1 , 7 })?\b |
U.S. Address |
The regex matches on a full U.S. Address. For example:
|
\d{ 1 , 5 }(\s[\w-.,]*){ 1 , 6 },\s[A-Z]{ 2 }\s\d{ 5 }\b |
Full name |
The regex matches on a string that contains “Full name“ keyword and 2 or 3 words. For example:
|
Full name:\s[A-Z][a-z]+(?:[ \t]*[A-Z]?[a-z]+)?[ \t]*[A-Z][a-z]+\b |
U.S. Driver license number |
The regex matches on a State Driver's license number. For example:
|
California: \b[A-Za-z]{ 1 }[ 0 - 9 ]{ 7 }\b Texas: \b[ 0 - 9 ]{ 7 , 8 }\b Florida: \b[A-Z]{ 1 }[ 0 - 9 ]{ 12 }\b |
U.S. Bank Account number |
The regex matches on a string that contains the “Bank Account Number“ keyword and an 8 to 17 digits number. For example:
|
Bank Account Number\W*\d{ 8 , 17 }\b |
U.S. Passport number |
The regex matches on a string that contains a Passport related keyword and a 9 digits number. For example:
|
(Passport Number|Passport No|Passport #|Passport#|PassportID|Passportno|passportnumber)\W*\d{ 9 }\b |
Date of Birth |
The regex matches on a date with the YYYY/MM/DD format and a "Date of birth:" or "Birthday:" prefix (Year min: 1900, Year max: 2020). For example:
|
(Date of birth:|Birthday:)\s+(?: 19 \d{ 2 }| 20 [ 01 ][ 0 - 9 ]| 2020 )[-/.](?: 0 [ 1 - 9 ]| 1 [ 012 ])[-/.](?: 0 [ 1 - 9 ]|[ 12 ][ 0 - 9 ]| 3 [ 01 ])\b |
The regex matches on a date with the DD/MM/YYYY format and a "Date of birth:" or "Birthday:" prefix (Year min: 1900, Year max: 2020). For example:
|
(Date of birth:|Birthday:)\s+(?: 0 [ 1 - 9 ]|[ 12 ][ 0 - 9 ]| 3 [ 01 ])[-/.](?: 0 [ 1 - 9 ]| 1 [ 012 ])[-/.](?: 19 \d{ 2 }| 20 [ 01 ][ 0 - 9 ]| 2020 )\b |
|
The regex matches on a date with the MM/DD/YYYY format and a "Date of birth:" or "Birthday:" prefix (Year min: 1900, Year max: 2020). For example:
|
(Date of birth:|Birthday:)\s+(?: 0 [ 1 - 9 ]| 1 [ 012 ])[-/.](?: 0 [ 1 - 9 ]|[ 12 ][ 0 - 9 ]| 3 [ 01 ])[-/.](?: 19 \d{ 2 }| 20 [ 01 ][ 0 - 9 ]| 2020 )\b |