I need a regular expression in javascript which allows all characters except for following characters <>_ ;{}[]
Following is the regular expression which i have tried this[regex] checks for allowed characters.
"^[A-Za-z0-9\s~!@#$%^&*()|\"\':?\/.+=,.-]*$"
but it is failing for following string ~!@#$%^&*()|\"':?/.,ab-=12+
Why not use a negated class instead of putting all of them in a character class? It's easier to read and faster in execution.
/^[^<>_ ;{}\[\]]+$/
Just use RegExp.test
with the above regex.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments