View Full Version : help with simple regular expression code

07-21-2002, 09:21 AM
$name = '@^#@#';
if(ereg("([[:punct:]]+)[[^:alnum:]]", $name)) echo "yes";

ok, im a little stumped on regular expression. what im trying to do above is make sure th $name string contains all punctuation marks and not a single letter or numerial. however, it doesn't. why?

07-22-2002, 07:03 AM
That seems to be a smilie-code-polluted RegExp indeed... ;)

I would simply test if a character appears that is not in the "punct" class.

$name = '@^#@#';
if(!ereg("[^[:punct:]]", $name)) {
echo "yes";

Though I still wonder for which application this would be needed.