[Israel.pm] RegEX Failure

Gaal Yahas gaal at forum2.org
Sat Sep 23 03:53:08 PDT 2006


60 for seconds is actually sometimes right (more often than you'd
think!).

   http://en.wikipedia.org/wiki/Leap_second

On Fri, Sep 22, 2006 at 06:35:17PM +0300, Georges EL OJAIMI wrote:
> Hello,
> 
> This is a sample of valid time:
> 
> 09/22/2006 17:59:18
> 
> If the user enter 60 for minutes or seconds it is wrong! and so on...
> 
> Best regards,
> Georges
> 
> > 
> > From: "Gabor Szabo" <szabgab at gmail.com>
> > Date: 2006/09/22 Fri PM 05:36:31 EAT
> > To: "Perl in Israel" <perl at perl.org.il>
> > Subject: Re: [Israel.pm] RegEX Failure
> > 
> > On 9/22/06, Georges EL OJAIMI <g-ojaimi at cyberia.net.lb> wrote:
> > > Hello,
> > >
> > > I have a Regular expression that check for valid date/time insertion in a database. Sometimes this code verify abnormal time entry and other time fails.
> > > Can you please check what is wrong in it:
> > >
> > > (1[0-2]|0?[1-9])[\\-\\/](0?[1-9]|[1][0-9]|3[01])[\\-\\/]((19|20)\\d{2}) (0?[0-9]|[1][0-9]|[2][0-3]):(0?[0-9]|[1-5][0-9]):(0?[0-9]|[1-5][0-9])
> > 
> > It is very hard to check such a regex, especially without examples of
> > input strins. Maybe you could share with us examples of strings that that
> > are recognized correctly and examples that are not recognized correctly.
> > 
> > In any case you could start to split this up. Using /x option you can
> > add spaces and
> > comments.
> > 
> > If I am not mistaken it would be like this:
> > 
> > /
> > (1[0-2]|0?[1-9])                          # add comments here
> > [\\-\\/]
> > (0?[1-9]|[1][0-9]|3[01])
> > [\\-\\/]                                       # should this be [\\\/-] instead?
> > ((19|20)\\d{2})                            # why double escape \\d  ?
> > [ ]                                            # is this a real space?
> > (0?[0-9]|[1][0-9]|[2][0-3])
> > :
> > (0?[0-9]|[1-5][0-9])
> > :
> > (0?[0-9]|[1-5][0-9])
> > /x
> > 
> > Gabor
> > _______________________________________________
> > Perl mailing list
> > Perl at perl.org.il
> > http://perl.org.il/mailman/listinfo/perl
> > 
> 
> _______________________________________________
> Perl mailing list
> Perl at perl.org.il
> http://perl.org.il/mailman/listinfo/perl

-- 
Gaal Yahas <gaal at forum2.org>
http://gaal.livejournal.com/



More information about the Perl mailing list