Regexp to match everything "except these"
I am wanting to sanitize a user input string in PHP using preg_replace() and the sanitized string should only be allowed to have plus or minus characters in it. I thought this would be a rather simple thing to do with regex, but I'm struggling to find some thing that will catch all the special characters (except for - and +) \w is a word and catches all chars Aa-Zz and 0-9 i think. \W is any non-word character so that will also catch + and - chars. Is there a regex to say \w and (\W excepting + OR -) ?