RegExp for username validation

Hi there

I need a custom regularexpression validation for username validation.

the validation is the same like a email adress validation except the requiremnt of a "@" -symbol and a toplevel check.

i need a regexp validation which checks whitespaces special charecters etc.

Can somebody help?




I’m using this one

array('username', 'match', 'pattern' => '/^[A-Za-z0-9_]+$/u'),

It allows only alphanumeric characters in addition to underscore

great! Thank you!

You can aslo supply error message, like this;


array('path', 'match' ,'pattern'=>'/^[a-z0-9_-]+\.[a-z]+$/i', 'message'=>'Field can contain only alphanumeric characters and hyphens(-).')


nice post