Re: Space in regex
| From: | Myron Turner | Date: | Fri, 17 Nov 2006 04:46:08 +0000 |
| Subject: | Re: Space in regex | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-244762@lists.php.net to get a copy of this message | ||
The underscore plus alphanumeric are included in \w, so to get a regex such as you want:
[\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.
Dotan Cohen wrote:
I'm trying to match alphanumeric characters, some common symbols, and spaces. Why does this NOT match strings containing spaces?: [A-Za-z0-9\'.&-:underscore::space:] I've also tried these, that also fail to match strings containing spaces: [A-Za-z0-9\'.&- :underscore:] [A-Z a-z0-9\'.&-:underscore:] [:space:A-Za-z0-9\'.&-:underscore:] All these regexes match strings containing the specified characters, but none of them match strings with spaces. Dotan Cohen http://what-is-what.com/ http://technology-sleuth.com/-- _____________________ Myron Turner http://www.room535.org http://www.bstatzero.org http://www.mturner.org/XML_PullParser/