At 1/23/2007 09:50 AM, Beauford wrote:
>          preg_match("/[EMAIL PROTECTED]&()*;:_.'\/\\\\ ]+$/", $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)) {


You don't need to escape the apostrophe if the pattern isn't quoted with apostrophes in PHP or delimited by apostrophes in the PREG pattern. But generally there's no harm in escaping characters unnecessarily; it just makes for messier code.

Here is a simple test of the regexp I recommended yesterday using the pattern:
        "/[EMAIL PROTECTED]&()*;:_.'\/\\\\ ]+$/"
http://juniperwebcraft.com/test/regexp_test_2007-01-23.php

If you're still having trouble getting this to work, please post a link to a page that demonstrates it not working and give us the complete PHP statements so we can find your error.

As an additional resource, here's Oliver Steele's RegExp workbench:
http://osteele.com/tools/rework/

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