This is a collection of regex expressions I often use. They are not perfect and 100% correct, but will catch most errors a user normally makes.

Email addresses

/^[a-zA-Z0-9.!#$%&’*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/

Phone number

/^(\+|0{1,2}?)[1-9][\d -]+\/?[\d -]+$/

Matches:

  • +49301234567
  • 00 49 30 123 – 456 – 7
  • 030 / 123 45 67
  • 030/1-2-3-4-5-6-7

German postalcode / ZIP

/^([0]{1}[1-9]{1}|[1-9]{1}[0-9]{1})[0-9]{3}$/

Regulärer Ausdruck für Deutsche Postleitzahlen

Date (dd.mm.YYYY)

/^\d{2}\.\d{2}\.\d{4}$/