Regular Expression To Validate Grade Point Average

A regular expression to validate Grade Point Average (GPA), which is between 0.00 and 4.00.

/^[0-3]\.?\d{0,2}|[4].[0]{0,2}$/

Matches:

  • 1.25
  • 3.6
  • 4.0

Non-matches:

  • 4.5
  • 5.0
  • .55