At 1/22/2007 04:56 PM, Beauford wrote:
I've probably read 100 pages on this, and no matter what I try it doesn't
work. Including all of what you suggested above - is my PHP possessed?

if(preg_match("/[EMAIL PROTECTED]&()*;:_.'/\\ ]+$/", $string)) { gives me
this error.

Warning: preg_match() [function.preg-match]: Unknown modifier '\' in
/constants.php on line 107

So if If you wouldn't mind, could you show me exactly what I need right from
the beginning and explain why it works.

i.e.

if(preg_match(what goes here", $string)) {
Echo "You got it";


Beauford,

Because you're using forward slashes /.../ to delimit your pattern, regexp is using the / in your character class to terminate your pattern:

        /[EMAIL PROTECTED]&()*;:_.'/

Then it's looking at the subsequent characters as pattern modifiers and gacking on the backslash. Even if you had a character there that it could accept as a pattern modifier, the character class would be incomplete (no closing bracket) so the pattern is doomed to fail.

You need to escape that forward slash in the character class:

        preg_match("/[EMAIL PROTECTED]&()*;:_.'\/

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("/[EMAIL PROTECTED]&()*;:_.'\/\\\\ ]+$/", $string)

Regards,

Paul
__________________________

Juniper Webcraft Ltd.
http://juniperwebcraft.com
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to