Problem with regular expression for checking date

hi,

I checking the validation of date here as

a=~/^(0[1-9]|1[012])//\d\d$/

It’s working fine, But when I give FEB-30 It’s accepting because in the
above expression it’s not restricted. So How do I impose the condition
in such a way that It would block for FEB-30 as well?

Wouldn’t it be more effective to use Date.parse to check for valid
dates? Regular Expressions for date checking are unreliable at best
since they’re more about patterns than actual values.

On Fri, Oct 18, 2013 at 4:06 PM, Raja gopalan [email protected]
wrote:


Posted via http://www.ruby-forum.com/.

Don’t forget about June 31, April 31, etc.
Also, Feb. 29, 2015, etc.

Harry

Hi Joel P.
ohhhhhhhhhhh yes, I haven’t thought of that. Thank you very much.

hi Harry
yes sure.

RAJ

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs