Regular expressions
| From: | Ori Staub | Date: | Mon, 31 Jul 2000 23:28:57 +0000 |
| Subject: | Regular expressions | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-9309@lists.php.net to get a copy of this message | ||
I need help with regular expressions.
I need to find the occurrence of characters in a string, however, for
simplicity, I would like to list them by "what is allowed".
I couldn't get it to work using eregi(), so i devised this little function,
but there must be an easier way! - please help
$legal_char_class = "[a-zA-Z0-9\.]";
$length = strlen($name);
for ($i=0; $i <= $length - 1 ; $i++){
$text_pos = $length - $i;
// break up string into array and test each character
$name_array[$i] = substr($domain_name, -$text_pos,1);
if (!ereg($legal_char_class,$name_array[$i])){
$error = true;
}
}// end for loop
--
Ori Staub
ori@_NO_SPAM_chikki.net