Re: [PHP] regexp novice

2012-05-20 Thread Geoff Shang
Stuart Dallas stu...@3ft9.com wrote: On 18 May 2012, at 14:50, Jim Giner wrote: Daft is a little harsh. :) 00:40 is just not a time value that is generally accepted. It may appear harsh, but as far as I'm concerned it is daft to make assumptions like that. You've essentially disallowed

Re: [PHP] regexp novice

2012-05-18 Thread Jim Giner
Jim Lucas li...@cmsws.com wrote in message news:4fb5decc.20...@cmsws.com... On 5/17/2012 9:52 PM, Jim Lucas wrote: How about this instead? pre?php $times = array( '100', # valid '1100', # valid '1300', # invalid '01:00', # valid '12:59', # valid '00:01', # valid '00:25pm', #

Re: [PHP] regexp novice

2012-05-18 Thread Jim Giner
Jim Lucas li...@cmsws.com wrote in message news:4fb5decc.20...@cmsws.com... On 5/17/2012 9:52 PM, Jim Lucas wrote: How about this instead? pre?php $times = array( '100', # valid '1100', # valid '1300', # invalid '01:00', # valid '12:59', # valid '00:01', # valid '00:25pm', #

Re: [PHP] regexp novice

2012-05-18 Thread Stuart Dallas
On 18 May 2012, at 14:32, Jim Giner wrote: OK - I don't yet understand how this works, but it seems to work for almost all cases. The one erroneous result I get is from a value of 0040 (which I convert to 00:40 before hitting the regexp). It comes thru as Ok. If you have a fix for that

Re: [PHP] regexp novice

2012-05-18 Thread shiplu
On Fri, May 18, 2012 at 7:34 PM, Stuart Dallas stu...@3ft9.com wrote: Based on your requirements, 00:40 is completely valid. Why do you think it should be invalid? 00:40 is not a valid 12-hour format. BTW I just found another non-regex approach. Its even faster. function

Re: [PHP] regexp novice

2012-05-18 Thread Jim Giner
Stuart Dallas stu...@3ft9.com wrote in message news:cc22e241-c1df-48e9-bf06-8a638a356...@3ft9.com... On 18 May 2012, at 14:32, Jim Giner wrote: OK - I don't yet understand how this works, but it seems to work for almost all cases. The one erroneous result I get is from a value of 0040

Re: [PHP] regexp novice

2012-05-18 Thread Stuart Dallas
On 18 May 2012, at 14:41, Jim Giner wrote: Stuart Dallas stu...@3ft9.com wrote in message news:cc22e241-c1df-48e9-bf06-8a638a356...@3ft9.com... On 18 May 2012, at 14:32, Jim Giner wrote: OK - I don't yet understand how this works, but it seems to work for almost all cases. The one

Re: [PHP] regexp novice

2012-05-18 Thread Jim Giner
times so 40 minutes after minute would be a) not practical and b) still not I meant to say 40 minutes after MIDNIGHT. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php

Re: [PHP] regexp novice

2012-05-18 Thread Jim Giner
Stuart Dallas stu...@3ft9.com wrote in message news:79538829-bfc4-43a4-a413-72247b145...@3ft9.com... On 18 May 2012, at 14:41, Jim Giner wrote: Stuart Dallas stu...@3ft9.com wrote in message news:cc22e241-c1df-48e9-bf06-8a638a356...@3ft9.com... On 18 May 2012, at 14:32, Jim Giner wrote: OK

Re: [PHP] regexp novice

2012-05-18 Thread Stuart Dallas
On 18 May 2012, at 14:50, Jim Giner wrote: Daft is a little harsh. :) 00:40 is just not a time value that is generally accepted. It may appear harsh, but as far as I'm concerned it is daft to make assumptions like that. You've essentially disallowed 12:nn am, but allowed 1:nn am, 2:nn

Re: [PHP] regexp novice

2012-05-18 Thread Andreas Perstinger
On 2012-05-17 22:37, Jim Giner wrote: Trying to validate an input of a time value in the format hh:mm, wherein I'll accept anything like the following: hmm hhmm h:mm hh:mm in a 12 hour format. My problem is my test is ok'ing an input of 1300. Here is my test: if (0 ==

Re: [PHP] regexp novice

2012-05-18 Thread Jim Giner
Stuart Dallas stu...@3ft9.com wrote in message news:aba011df-8cdf-4492-be4d-51c2b54c4...@3ft9.com... On 18 May 2012, at 14:50, Jim Giner wrote: Daft is a little harsh. :) 00:40 is just not a time value that is generally accepted. It may appear harsh, but as far as I'm concerned it is daft

Re: [PHP] regexp novice

2012-05-18 Thread tamouse mailing lists
On Thu, May 17, 2012 at 3:37 PM, Jim Giner jim.gi...@albanyhandball.com wrote: ok - finally had to come up with my own regexp - and am failing. Trying to validate an input of a time value in the format hh:mm, wherein I'll accept anything like the following: hmm hhmm h:mm hh:mm in a 12

Re: [PHP] regexp novice

2012-05-17 Thread shiplu
On Fri, May 18, 2012 at 2:37 AM, Jim Giner jim.gi...@albanyhandball.comwrote: ok - finally had to come up with my own regexp - and am failing. Trying to validate an input of a time value in the format hh:mm, wherein I'll accept anything like the following: hmm hhmm h:mm hh:mm in a 12

Re: [PHP] regexp novice

2012-05-17 Thread Yared Hufkens
Try this: /(0?[1-9]|[12][0-9]):?[0-5][0-9]/ FYI: ? is equal to {0,1}, and [1-9] to [123456789] (and therefore [1-2] to [12]). Am 17.05.2012 22:37, schrieb Jim Giner: ok - finally had to come up with my own regexp - and am failing. Trying to validate an input of a time value in the format

Re: [PHP] regexp novice

2012-05-17 Thread Jim Giner
Yared Hufkens y4...@yahoo.de wrote in message news:4fb5667d.7020...@yahoo.de... Try this: /(0?[1-9]|[12][0-9]):?[0-5][0-9]/ FYI: ? is equal to {0,1}, and [1-9] to [123456789] (and therefore [1-2] to [12]). Am 17.05.2012 22:37, schrieb Jim Giner: ok - finally had to come up with my own

Re: [PHP] regexp novice

2012-05-17 Thread Govinda
FWIW - I couldn't find much in the way of tutorials on the meanings of the various chars in regexp's. this helps alot: http://www.gskinner.com/RegExr/ you can paste your pattern (needle) in the top input, and hover over each char to see what it means in grep land. Paste your haystack in

Re: [PHP] regexp novice

2012-05-17 Thread Jim Giner
Thank you ! Govinda govinda.webdnat...@gmail.com wrote in message news:3e5dce87-29c1-4679-ad3a-53326435f...@gmail.com... FWIW - I couldn't find much in the way of tutorials on the meanings of the various chars in regexp's. this helps alot: http://www.gskinner.com/RegExr/ you can paste your

Re: [PHP] regexp novice

2012-05-17 Thread Jim Lucas
On 5/17/2012 1:57 PM, shiplu wrote: On Fri, May 18, 2012 at 2:37 AM, Jim Ginerjim.gi...@albanyhandball.comwrote: ok - finally had to come up with my own regexp - and am failing. Trying to validate an input of a time value in the format hh:mm, wherein I'll accept anything like the following:

Re: [PHP] regexp novice

2012-05-17 Thread Jim Giner
Jim Lucas li...@cmsws.com wrote in message news:4fb5b89e.8050...@cmsws.com... On 5/17/2012 1:57 PM, shiplu wrote: On Fri, May 18, 2012 at 2:37 AM, Jim Ginerjim.gi...@albanyhandball.comwrote: ok - finally had to come up with my own regexp - and am failing. Trying to validate an input of a

Re: [PHP] regexp novice

2012-05-17 Thread Jim Lucas
On 5/17/2012 8:07 PM, Jim Giner wrote: Jim Lucasli...@cmsws.com wrote in message news:4fb5b89e.8050...@cmsws.com... On 5/17/2012 1:57 PM, shiplu wrote: On Fri, May 18, 2012 at 2:37 AM, Jim Ginerjim.gi...@albanyhandball.comwrote: ok - finally had to come up with my own regexp - and am

Re: [PHP] regexp novice

2012-05-17 Thread Jim Lucas
On 5/17/2012 9:52 PM, Jim Lucas wrote: How about this instead? pre?php $times = array( '100', # valid '1100', # valid '1300', # invalid '01:00', # valid '12:59', # valid '00:01', # valid '00:25pm', # invalid '', # valid 'a00', # invalid '00', # invalid ); foreach ( $times AS $time ) echo

Re: [PHP] regexp novice

2012-05-17 Thread Shiplu
Jim L. I did't actually consider that wide range of time values. Here is an update. Still this can be written without help of regex. I must add one more thing that a '00:01' is invalid in 12 hour format. OP wants it to be 12-hour format. function valid_time($time){ $m = substr($time,