RE: [PHP] preg_match problem
| From: | Beauford | Date: | Tue, 23 Jan 2007 17:50:28 +0000 |
| Subject: | RE: [PHP] preg_match problem | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-247635@lists.php.net to get a copy of this message | ||
> You need to escape that forward slash in the character class:
>
> preg_match("/^[A-Za-z0-9!@#$%&()*;:_.'\/
>
> Also, you've got only two backslashes in your char class. PHP is
> reducing this to a single backslash before the space character. I
> think you intend this to be two backslashes in the pattern so you
> need four backslashes in PHP:
>
> preg_match("/^[A-Za-z0-9!@#$%&()*;:_.'\/\\\\ ]+$/", $string)
>
On top of this, every time a ' is entered it gets preceded by \. If I just
check for the characters like below that doesn't happen. Totally confused.
if(preg_match("/^[-A-Za-z0-9_.' ]+$/", $string)) {