escaping characters used by regex

This commit is contained in:
Miodec 2021-01-06 22:02:31 +00:00
parent 79afe812f5
commit 254a0414a5

View file

@ -2097,7 +2097,8 @@ function updateSuggestedCommands() {
let foundcount = 0;
$.each(inputVal, (index2, obj2) => {
if (obj2 == "") return;
let re = new RegExp("\\b" + obj2, "g");
let escaped = obj2.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
let re = new RegExp("\\b" + escaped, "g");
let res = obj.display.toLowerCase().match(re);
if (res != null && res.length > 0) {
foundcount++;