Re: How to test a string for invalid chars ?
Also sprach Pjotr Wedersteers:
> I think I am having a big blind-spot day. How does one test a
> form-sent string for any disallowed characters again ? I want only
> a.z,A..Z,0..9,- and _ in the input... Thanks.
if(!preg_match('/^[a-zA-Z0-9_-]*$/', $input)) {
echo 'Invalid input!';
}
else {
echo 'Well done!';
}
|