diff --git a/src/yoptascript.js b/src/yoptascript.js index 7cc29f3..3818bda 100644 --- a/src/yoptascript.js +++ b/src/yoptascript.js @@ -2440,7 +2440,17 @@ var dictionary = [ ]; function escapeRegExp(str) { - return "\\b" + str.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&') + "\\b"; + var str = str.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&'); + + if (/^\w/.test(str)) { + str = "\\b" + str; + } + + if (/\w$/.test(str)) { + str += "\\b"; + } + + return str; } function yoptReplaceAll(str, search, replacement) {