Reply to Re: [PHP] Regexp trouble

Your name:

Reply:


Posted by Frank Armitage on 11/24/05 19:23

Andy Pieters wrote:
> Hi list
>
> I still fail to understand why regular expressions are causing me such a hard
> time.
>
> <snip />

Hi!

Why don't you use 'preg_match'? And why do you use all those character
classes?


This:

<code>
$subject = 'Nov 22 06:51:36';
$pattern = '/^(\w{3})\s(\d{2})\s(\d{2}):(\d{2}):(\d{2})/';
if (preg_match($pattern, $subject, $matches)) {
print_r($matches);
}
</code>


nicely prints:

Array
(
[0] => Nov 22 06:51:36
[1] => Nov
[2] => 22
[3] => 06
[4] => 51
[5] => 36
)


Bye
Frank

--
tradeOver | http://www.tradeover.net
....ready to become the King of the World?

[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

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