Re: regexp novice

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



"Stuart Dallas" <stuart@xxxxxxxx> wrote in message 
news:79538829-BFC4-43A4-A413-72247B145CDC@xxxxxxxx...
On 18 May 2012, at 14:41, Jim Giner wrote:

> "Stuart Dallas" <stuart@xxxxxxxx> wrote in message
> news:CC22E241-C1DF-48E9-BF06-8A638A356459@xxxxxxxx...
>> 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 I'd appreciate it - otherwise I'll have to devote 
>>> some
>>> book-time to mastering this string and come up with a fix myself.
>>
>> Based on your requirements, 00:40 is completely valid. Why do you think 
>> it
>> should be invalid?
>>
> Don't know how you write the time, but I've never used a time of 00:40.
> Yes, I realize that my shorthand time string is missing a key ingredient 
> of
> am/pm, but 12:40 would be the time in my mind regardless of the status of
> the sun.  In my speccific use of this code, all times would be 'daylight'
> times so 40 minutes after minute would be a) not practical and b) still 
> not
> a recognized time in a 12-hour format.  Yes - in 24-hour formats, 00:40 is
> correct, but my initial post did reference my need of a 12-hour format
> solution.

Sounds daft to me, but they're your requirements. The "fix" is simple?

( 0 <= (int) $m[1] && 12 >= (int) $m[1] ) &&

becomes

( 1 <= (int) $m[1] && 12 >= (int) $m[1] ) &&

-Stuart

-- 
Stuart Dallas
3ft9 Ltd
http://3ft9.com/=

Daft is a little harsh.  :)  00:40 is just not a time value that is 
generally accepted.

As for you patch thought - THAT is generally accepted.  Works great now. 
Thank you.

Now all I have to do is read up on this stuff so I can understand how it 
works.  But first - golf! 



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux