tags:

views:

26

answers:

1

How do i do a regular expression that will allow everything except !@$%^&*()_+={}[]|\:";'<>,.?/ (If i need to detect more than these can I simply add them into the regexp later?)

I intend using this to check if these character are present in postal addresses a user submits. So if they were there, I could reject the address.

Thanks

+2  A: 

You should include allowed characters instead of excluding almost everything :

[\w+-]*

But if you want to really exclude those chars :

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

Resources :

Colin Hebert
So if I wanted to allow or disallow a few characters, i could simply add or remove them from the expression. Right?
Norman
Yes, to allow them, add them to the first expression. If you want to remove use the second one.
Colin Hebert