On Wednesday 21 July 2004 10:04, John Van Pelt wrote:

> 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

As John has previously suggested the best way to go about this is to remove 
anything which is not in the set of acceptable characters, which for the 
above is:

  $new = preg_replace('/[^A-Za-z-\()\s]/', '', $old);

Then check that $new is not empty().

-- 
Jason Wong -> Gremlins Associates -> www.gremlins.biz
Open Source Software Systems Integrators
* Web Design & Hosting * Internet & Intranet Applications Development *
------------------------------------------
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-general
------------------------------------------
/*
Finagle's Seventh Law:
        The perversity of the universe tends toward a maximum.
*/

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to