preg_match question

From: Date: Wed, 21 Jul 2004 02:04:54 +0000
Subject: preg_match question
Groups: php.general 
Request: Send a blank email to php-general+get-191256@lists.php.net to get a copy of this message
I am a semi-newbie at php and a complete newbie to regex.... What am I doing wrong here? function isWord($element) { return !preg_match ("/[^A-Za-z\-\(\)\s]/", $element); } I want to test the string $element and make sure that it contains nothing but: - characters A-Z - characters a-z - hyphen - parentheses (open and close) - space character or its equivalent Another issue that may be related to the problem (in case my function above is correct, which I doubt), is that $element is being returned as a $_POST value from a form field... and it CAN be empty. Will my function choke on that? Do i need to test separately for ''? Thanks in advance, -john

« previous php.general (#191256) next »