Re: Regexp trouble

From: Date: Thu, 24 Nov 2005 17:23:25 +0000
Subject: Re: Regexp trouble
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-226411@lists.php.net to get a copy of this message
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?

« previous php.general (#226411) next »