How To Use Just Asterisk Wildcard When Searching?
I want to just support asterisk(*) wildcard not regex. This is my code : for example : checkNames[i] = 'Number of ongoing MS sessions' var checkName = checkNames[i].split('*').jo
Solution 1:
Borrowing heavily from this question, I think you are after something like the following:
var checkName =
checkNames[i]
.split("*")
.map(function (s) { return s.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&'); })
.join(".*");
This escapes each part of the regular expression after splitting on the *
character, ready to be joined back with .*
.
Post a Comment for "How To Use Just Asterisk Wildcard When Searching?"