note 102533 rejected from function.preg-match by danbrown

[email protected] Sat, 19 Feb 2011 17:33:45 -0800
Newsgroups php.notes
Message-ID <[email protected]>
Note Submitter: adv at fotobase dot org 

----

Please, help me!
What is the valid regex for filtering logins?

The login consists only from characters a-z A-Z, 0-9

but there is no whitespaces.

for example

somebody - valid login
somebody123 - valid login
123somebody123 - valid login
et cetera

some body - invalid login

these regexs doesn't works for me

/[0-9A-Za-z]/i 
/[0-9a-Z]/i
/[0-9a-Z^ ]/i
/[0-9a-Z^\s]/i

i use this code

if (preg_match("/[0-9A-Za-z]/i",$login))
{
$ok=1;
}