Programming C# C++ (7) Delphi (617) Java (8) JavaScript (31) perl (9) mysql (3) perl CGI (3) php (4) VBScript (1) Visual Basic (1) ![]() |
Check if a user name contains non-alphanumeric characters
![]() 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:
Comments:
|