Re: Regexp trouble

From: Date: Thu, 24 Nov 2005 17:27:10 +0000
Subject: Re: Regexp trouble
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-226412@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.
er, because they are hard? hey you failed! we have a club :-)
I used and tested my regexp in kregexpeditor (comes with Quanta [kdewebdev]) but when I put it in the php script it fails. ereg('^([\w]{3,3})[\s]([\d]{2,2})[\s]([\d]{2,2})[:]([\d]{2,2})[:]([\d]{2,2})'
I always use the preg_*() functions myself. and I always have to specify regexp delimiters ... $re = "#^([\w]{3,3})[\s]([\d]{2,2})[\s]([\d]{2,2})[:]([\d]{2,2})[:]([\d]{2,2})#"; $st = "Nov 22 06:51:36"; echo (preg_match($re, $st) ? "Yes":"No"),"\n"; I ran the above and it returned 'Yes' for me.
Does not match my query string. Which is Nov 22 06:51:36 Any ideas why? I mean Line start, followed by 3 word chars, followed by a space, followed by 2 digits, followed by a space, followed by two digits, folowed by a colon followed by 2 digits and followed by a colon, should match that date? With kind regards Andy


« previous php.general (#226412) next »