- preg_match: documentation ( source)
- preg_quote: documentation ( source)
<?php
$allowed_chars = 'a\-z 0\-9~%\.\:_\-';
$str = 'renewal';
if ( ! preg_match("/^[".preg_quote($allowed_chars)."]+$/i", $str)){
echo "Unallowed!!!!";
}else{
echo "Looks fine";
}