PDA

View Full Version : Validating whether string contains llegal chars



avelonx
Jun 29th, 2002, 06:50 PM
Could someone please give me a code that will check if a string contains only numerical and alphabetical characacters in it..
ya know..

abcedfghijklmnopqrstuvwxyz
1234567890

Astro-Boy
Jul 1st, 2002, 04:51 AM
$str = 'lkdsaglfkgslfkjagsd';
if (preg_match('/[^\\dA-Za-z]/', $str)) {
die('illegal characters!');
}

- Mark