For all us security paranoids Here are eight practical PHP regular expressions i found on the web which came very handy to me:
Note: Scroll down to get the latest/correct versions of these Regular expressions
Validating a Username:
Something often overlooked, but simple to do with a regular expression would be username validation. For example, we may want our usernames to be between 4 and 28 characters in length, alpha-numeric, and allow underscores.