Regular Expression To Match Even Or Odd Numbers

The regular expressions below will match only even or odd numbers such as zip code, state id, or passport number.

Even Number:

  • 2
  • 1234
  • 1024
/^\d*[02468]$/g

Odd Number

  • 3
  • 2771
  • 4321
/^\d*[13579]$/g