I found many solutions online for regex matching the first occurrence of a string, a certain character, a word, etc, but I have yet to find a solution for matching the first occurrence of a SET of characters (or in my case, NOT matching a set of characters).
e.g. I have a string as below (in javascript):
var testString = '~!@#$%^&*()_+|}{POIUYTREWQ":?><asdfghjklm,./;[]\=-0987654321`~!@#$%^&*()_+|}{POIUYTREWQ":?><asdfghjklm,./;[]\=-0987654321`~!@#$%^&*()_+|}{POIUYTREWQ":?><asdfghjklm,./;[]\=-0987654321`'
As you can see, there are many, many, many occurrences of weird characters within testString.
I put up a regex match to show me which are the offending characters as below:
var regTest = /[^A-Za-z0-9.,?()@\[\]\-\/ ]/g;
var wrongChar = testString.match(regTest);
Now, my problem is that even though wrongChar nicely returns an array of the non-matched characters, it gives me every occurrence of the characters, as below:
~,!,#,$,%,^,&,*,_,+,|,},{,",:,>,<,;,\,=,`,~,!,#,$,%,^,&,*,_,+,|,},{,",:,>,<,;,\,=,`,~,!,#,$,%,^,&,*,_,+,|,},{,",:,>,<,;,\,=,`
Is there way to give me only the FIRST occurrence of every unwanted character in a quick way(such as a change in my regex), or would I have to create 2 arrays to keep testing if a character has already been saved inside wrongChar(the long method)?