I have this variable:
var search = "dummy";
var replace = "<strong>" + search + "</strong>";
var contents = "my contents are here and this dummy value should be bolded...";
contents.replace(/search/gi, replace);
So, How can I set this “search” variable under my RegEx pattern, followed with /gi settings for my match.
try
you should also be aware of the fact, that you have to escape certain sequences. Btw. you have to double escape these when you’re constructing a regex like this (new RegExp(‘\\n’) -> matches \n)