Link to home
Start Free TrialLog in
Avatar of jxbma
jxbmaFlag for United States of America

asked on

What is the regex expression for validating year in the YYYY format?

Hi:

I've got pretty limited experience dealing with regex expressions.

I'm looking for a regex expression to validate the following: Valid Year in the form YYYY.
We want to check for years in the 1000's through to the 2000's.

I came up with something like this:
^(15|16|17|18|19|20)\d\d

Open in new window

This would work for years from 1500 - 2099
But I think there must be something a little cleaner/more elegant.

Thanks,
JohnB
ASKER CERTIFIED SOLUTION
Avatar of it_saige
it_saige
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of jxbma

ASKER

Awesome.

JB