We have been using the following js/regex to find and replace all non-alphanumeric characters apart from - and +
outputString = outputString.replace(/[^\w|^\+|^-]*/g, "");
However it doesn't work entirely - it doesn't replace the ^ and | characters. I can't help but wonder if this is something to do with the ^ and | being used as meta-characters in the regex itself.
I've tried switching to use [\W|^+|^-]
, but that replaces the - and +. I thought that possibly a lookahead assertion may be the answer, but I'm not very sure how to implement them.
Has anyone got an idea how to accomplish this?