Forum Moderators: coopster
function allowedChars($str) {
$charArray = array(
/* Symbols etc */
'-', '_', '\,', '\.', ' ',
/* Numbers */
'1', '2', '3', '4', '5','6', '7', '8', '9', '0',
/* English */
'A', etc
/* Latin */
etc
/* Greek */
etc
);
$allowed = implode("", $charArray);
// Strip everything except $allowed
// u -> UTF-8 validity of the pattern is checked
$str = preg_replace('/[^' . $allowed . ']+/u', '', $str);
return $str;
} perlredocs in that original thread rather than assuming anybody reading it would know what Perl is and how to use Perl regular expressions. Here is the current online man page for Perl regular expressions: