Regular Expression: Allow letters, numbers, and spaces (with at least one letter or number)

Posted by makeee on Stack Overflow See other posts from Stack Overflow or by makeee
Published on 2009-02-23T00:43:54Z Indexed on 2010/04/03 22:33 UTC
Read the original article Hit count: 209

Filed under:
|

I'm currently using this regex ^[A-Z0-9 _]*$ to accept letters, numbers, spaces and underscores. I need to modify it to require at least one number or letter somewhere in the string. Any help would be appreciated!

This would be for validating usernames for my website. I'd actually like to support as many characters as I can, but just want to ensure that I prevent code injection and that characters will display fine for all users. So I'm definately open to regex validation suggestions that would support a wider set of characters.

© Stack Overflow or respective owner

Related posts about regex

Related posts about JavaScript