Reply to Re: regular expression for time

Your name:

Reply:


Posted by Al on 08/29/05 17:32

babu wrote:
> HI,
>
> how can i write regular expression for time in 24-hour format i:e, HH:MM:SS. using preg_match.
>
> thanks
> babu
>
>
> ---------------------------------
> How much free photo storage do you get? Store your holiday snaps for FREE with Yahoo! Photos. Get Yahoo! Photos

You need to be more specific about:

What is before and after the time string. It's probably white-space. That so?

Can your HH, values be without the leading zero, e.g., 2:12:15.

Can you be certain that MM and SS will be included. If the time is entered by users, they can get lazy and give you
"2", for example.

Given the simplest case. $pattern= "%\s(\d\d:\d\:\d\d)\s%"; ["%" is simply the delimitor, it can be almost any
thing.] The \s is optional, it says white-space.

$num= preg($pattern, $string [,$match_array]) $time_value= $match_array[1]; $num of matches in case you want to test
for none or more than 1.

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация