Re: Re: Space in regex
| From: | Paul Novitski | Date: | Fri, 17 Nov 2006 05:22:39 +0000 |
| Subject: | Re: Re: Space in regex | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-244764@lists.php.net to get a copy of this message | ||
At 11/16/2006 08:46 PM, Myron Turner wrote:
The underscore plus alphanumeric are included in \w, so to get a regex such as you want:Not actually. Inside a character class, a dot is just a period. You may escape it (or any other character) but you don't need to. To quote the manual: ______________________ Meta-characters ... In a character class the only meta-characters are: \[\w\s\.\-&\']+ You should escape the dot because the unescaped dot stands for any single character, which is why .* stands for any and all characters.
general escape character^
negate the class, but only if the first character-
indicates character range]
terminates the character class... Square brackets ... A closing square bracket on its own is not special. If a closing square bracket is required as a member of the class, it should be the first data character in the class (after an initial circumflex, if present) or escaped with a backslash. ... All non-alphanumeric characters other than \, -, ^ (at the start) and the terminating ] are non-special in character classes, but it does no harm if they are escaped. ______________________ http://ca.php.net/manual/en/reference.pcre.pattern.syntax.php Regards, Paul