...

View Full Version : help with simple regular expression code



Extrovertive
07-21-2002, 08:21 AM
<?php
$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?

mordred
07-22-2002, 06: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.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum