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
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php