RE: [PHP] preg_match problem

From: Date: Tue, 23 Jan 2007 17:28:54 +0000
Subject: RE: [PHP] preg_match problem
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-247630@lists.php.net to get a copy of this message
> if (preg_match('/^[A-Za-z0-9!@#$%&()*;:_.'\\/\\\\ ]+$/', $string)) > > Use single quotes and double back-slashes. PHP strings also > have escape sequences that use the back-slash as escape > character, that's why you have to double them. And single > quotes to avoid the $ character interpreted as the start of a > variable. > > PS: Will we be risking going the perl way if we ask that PHP > supported regular expressions natively (I mean: without > having to provide them as strings)? I have tried all the examples posted in the last couple of days, and none of them, including the above work. Is there another solution to this, as this just seems to be way to buggy? Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /constants.php on line 107 Warning: Unexpected character in input: '\' (ASCII=92) state=1 in //constants.php on line 107 Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /constants.php on line 107 Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /constants.php on line 107 Warning: Unexpected character in input: '\' (ASCII=92) state=1 in //constants.php on line 107 Warning: Unexpected character in input: '\' (ASCII=92) state=1 in //constants.php on line 107 Parse error: syntax error, unexpected ']' in //constants.php on line 107

« previous php.general (#247630) next »