So I am working on something which has a search field to highlight matching strings/ characters from the data, to achieve this I am passing search query as regrex matching group. e.g.
var pattern =
new RegExp( "("+ matchThis+")" );
And to eliminate special characters I tried this
var pattern =
new RegExp( "[^.#&]("+ matchThis+")" );
but it doesn't work.
Any suggestions how to achieve above mentioned functionality, little explanation would help a lot as I am new to RegExp.