Re: Space in regex

From: Date: Mon, 20 Nov 2006 23:48:28 +0000
Subject: Re: Space in regex
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-244919@lists.php.net to get a copy of this message
At 11/20/2006 03:12 PM, Richard Lynch wrote:
. means *ANY* character, unless you escape it for PCRE \. is what PCRE needs. ...
'/[A-Z0-9\\'\\.& _-]/i'
No, this is incorrect. In a character class definition, "." is the period character, not the 'any' metacharacter. It doesn't break regexp to unnecessarily escape characters as in [\.], but let's not give people the impression that it's required. In a character class the only characters you need to escape are: \ the escape character itself ^ the negate symbol, but only if it's in the first position ] the close-bracket, unless it's in the first position - the range indicator, unless it's in the first or last position See my posting to this thread of 11-17: http://marc.theaimsgroup.com/?l=php-general&m=116374098719827&w=2 Here's the relevant section from the PCRE Pattern Syntax documentation: http://php.net/manual/en/reference.pcre.pattern.syntax.php#regexp.reference.squarebrackets Regards, Paul __________________________ Juniper Webcraft Ltd. http://juniperwebcraft.com

« previous php.general (#244919) next »