Sample regular expressions

Name

Description

Regular Expression

Email

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:

  • Local: 754-3010

  • Domestic: (541) 754-3010

  • International: +1-541-754-3010

  • Dialed in the U.S.: 1-541-754-3010

  • With extension number:

    • (541) 754-3010 x350

    • (541) 754-3010 Ext. 350

    • (541) 754-3010 Extension 350

(?:(?:\+?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:

  • 1775 Washington St, Hanover, MA 02339

  • 350 E Fairmount Ave,
    Lakewood, NY 14750

\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: Lisa garrison Simpson

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: A1234567

  • Texas: 1234567 or 12345678

  • Florida: A123456789123

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: 12345678

  • Bank Account Number 12345678901234567

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: 123456789

  • Passport No. 123456789

(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: 1900/12/01

  • Date of birth: 2019.01.25

  • Birthday: 2099-10-30

(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: 12/01/1900

  • Date of birth: 01.12.2019

  • Birthday: 10-10-2099

(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: 12/01/1900

  • Date of birth: 01.25.2019

  • Birthday: 10-30-2099

(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