Friday, May 10, 2024
 Popular · Latest · Hot · Upcoming
55
rated 0 times [  58] [ 3]  / answers: 1 / hits: 40266  / 15 Years ago, tue, september 29, 2009, 12:00:00

Can anyone help me with this regex? I need something which will ALLOW:



0-9
a-z
A-Z
spaces
hyphens
apostrophes



But disallow all other special characters.



I've got this, but it's not working:



regex:/^[0-9a-zA-Z/ /-'_]+$/,


Thanks for any help!


More From » regex

 Answers
31

You should remove the double quotes around the regex:



regex: /^[0-9a-zA-Z -'_]+$/,


Also make sure you use backslashes to escape special characters, not forward slashes.


[#98596] Thursday, September 24, 2009, 15 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
tayaw

Total Points: 749
Total Questions: 88
Total Answers: 86

Location: Djibouti
Member since Sun, Feb 27, 2022
2 Years ago
tayaw questions
;