JSFiddle - React, Tailwind, and code Playground
by xxxvvvxxx
JavaScript
var stringToGoIntoTheRegex = "abc";
var regex = new RegExp("#" + stringToGoIntoTheRegex + "#", "g");
// at this point, the line above is the same as: var regex = /#abc#/g;
var input = "Hello this is #abc# some #abc# stuff.";
var output = input.replace(regex, "<mark>$&</mark>");
alert(output); // Hello this is !! some !! stuff.