Reputation: 439
I feel super fail asking this... but I've been trying to make sure my values are alphanumeric, and I can't do it! if(!preg_match("^[0-9]+:[a-zA-Z]+$/", $subuser)){ $form->setError($field, "* Username not alphanumeric"); }
I did a search here and couldn't find anything... probably because this is so rudimentary =__=
Also, does anyone know of a resource (aside from PHP.net) that has a list of operators for Preg_match, and what they mean?
Thanks!
Upvotes: 0
Views: 4065
Reputation: 4829
if you just want to make sure they are alphanumeric,
if( preg_match(/\W/), $subuser) {
$form->setError($field, "* Username not alphanumeric");
}
will work (match any non-alphanumeric entry). But it looks like your username might require some structure.
I thought "Mastering Regular Expressions" was one of the better programming books I've read, and I've read at least a couple hundred by now.
Upvotes: 0
Reputation: 620
The function ctype_alnum() is better in this case.
For the operators : official stuff.
Upvotes: 3