Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
61
rated 0 times [  68] [ 7]  / answers: 1 / hits: 50809  / 12 Years ago, fri, may 4, 2012, 12:00:00

i want to validate my text field with below:

1. alpha-numeric

2. And all special characters

i am not good in regex can anyone help me out creating a regex for above things.


More From » regex

 Answers
107

alphanumeric Strings are matched like this:



^[a-zA-Z0-9]+$


It matches any string that only contains of the listed chars and is at least one char long.



With special chars it would work the same way.



But what do you consider to be a special char?



For !@#$%^&*()+=-[]';,./{}|:<>? – being the set of special chars, the regex would look like this:



^[@!#$^%&*()+=-[]\';,./{}|:<>? ]+$


Again, all the allowed characters are listed. The ones used within regexes as commands or quantifiers have to be escaped with a .


[#85786] Thursday, May 3, 2012, 12 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
gabriellagiselc

Total Points: 654
Total Questions: 99
Total Answers: 106

Location: Burkina Faso
Member since Thu, Dec 23, 2021
2 Years ago
;