I am looking to find a keyword match in a string. I am trying to use word boundary, but this may not be the best case for that solution. The keyword could be any word, and c
Check whether the keyword already begins with a special character. If it does, don't include it in the regular expression.
var re; if ("#@".indexOf(keyword[0]) == -1) { re = new RegExp(`[@#]?\b${keyword}\b`); } else { re = new RegExp(`\b${keyword}\b`); }