Re: preg_match problem
| From: | Paul Novitski | Date: | Tue, 23 Jan 2007 16:53:02 +0000 |
| Subject: | Re: preg_match problem | ||
| References: | 1 2 3 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-247629@lists.php.net to get a copy of this message | ||
At 1/23/2007 04:52 AM, Martin Alterisio wrote:
if (preg_match('/^[A-Za-z0-9!@#$%&()*;:_.'\\/\\\\ ]+$/', $string))Close but no cigar. Because you're using apostrophe to quote the expression, PHP interprets the apostrophe inside the character class as ending the quoted expressions and fails. Both PHP and PREG need you to escape any character inside a string that's used to delimit the string itself. (I think it's just as important to test the code we offer to solve problems on the list as it is to research problems before posting them. This is all getting archived....) Regards, Paul __________________________ Juniper Webcraft Ltd. http://juniperwebcraft.com