0

HI,

I am trying to highlight a set of keywords using javascript and regex, I facing one problem, my keyword may contain literal and special characters as in @text #number etc. I am using word boundary to match and replace the whole word and not a partial word (contained within another word).

var pattern = new regex('\b '( + keyword +')\b',gi); here this expression matches the whole keywords and highlights them, however incase if any keyword like "number:" do not get highlighted.

I am aware that \bword\b matches for a word boundary and special characters are non alphanumeric characters hence are not matched by the above expression.

Can you let me know what regex expression I can use to accomplish the above.

thanks,

Bhupen

Bhupen
  • 41
  • 1
  • 2

0 Answers0