Re: Space in regex

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux