Saturday, September 5, 2009

Regex For Creating Usernames

A regular expression (called regex) is a way for a programmer to instruct how a program should look for a specified pattern in text and then what it should do when each pattern match is found. Rather than going through each character of a string and doing matches, regex makes life easier for programmers to do search and matches. This sample regex is a good pattern for use in creating usernames.

The regex below means that only alphanumeric (only lowercase letters) are allowed including an underscore and a dot.

^[a-z0-9_.]$

No comments: