regex year

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,
I need to validate any year in format
05 and 2005 and not 200 or 005. I am currently using ^(\d{4})$.

Thanks
 
You can try

^(\d{2}){1,2}$

this regular expression accepts two or four numeric digits only.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top