Regex Find [ and other unusual character JavaScript

Hi im trying to make a regex to find any of these character: +_)(*&?%$#@!\+¬][}{¤|<>?/"

but i cant seem to get it to match some characthers. Plz help

i cant use /W because it will exclude characters like - or é

here is a exemple of my test

var str=" Is this % all there is ? > }[ " ;
var patt1=/[ +_)(*&?%$#@!\+¬][}{¤|<>?/"]/g;
document.write(str.match(patt1));

output : ?, >

it should also have found }[ % … cant seem to figure why

plz help , its probably something basic i guess but i cant find it lol.

Thank you .

Try escaping them by adding a \ in front of each one that isn’t recognised - most of those characters have special meanings in regular expressions and so need to be escaped in order to get back their normal meaning.

var str=“{}\\()<>\]\[\/?#!$@\”+*°|¤";
var patt1=/[{}\\()<>\]\[\/?#!$@"+
*°|¤]/g;
document.write(str.match(patt1));

this one is worcking THX.
I changed the order of the symbols and it worked and added \ for [,],\,/

Now in can use this for a input filter to see if the user is trying to input illegal character.
I had this idea to check for invalid character instead to look for good character.
I call it revese validation XD.

Sounds like you have an awful lot of valid characters then if only that small fraction of 0.000001% of the possible characters are the only ones that are invalid - take a look at http://en.wikipedia.org/wiki/List_of_Unicode_characters for a partial list of all the characters you are allowing by only blocking those few.

Im aware of that :slight_smile: but its ok for what i want.