I have a contentEditable="true"
div in which, as I type, I would like to wrap the last word before the caret in strong.
I am trying to use regex for this. I made it work for when I type of the string in the regex statically, but it does not work when I pass the word dynamically via like this:
textBeforeCaret.replace(`/${lastWord}$(?!.*?${lastWord})/`, '<strong>$&</strong>')
Thank you for your help!