perl CGI (3)
Visual Basic (1)
New related comments
Number of comments in the last 48 hours
Greating GIF, JPEG or PNG images with perl
Check if a user name contains non-alphanumeric characters
This article has not been rated yet. After reading, feel free to leave comments and rate it.
Question:On my web site, a user may put in a desired user name and I have to check that it only contains letters, digits, or the @ and . characters. How can I do that with a regular expression (regex)?
Answer:The allowed characters are described as A-Za-z0-9.
That are the intervals A-Z, a-z and 0-9. You can also substitute 0-9 with d (digit).
To check for the undesired character, use the ^ operator in front of it as shown below: