Just curious. what are the differences between?
var a=text.replace(/(Nullam|ligula|in)/ig,'`<b>$1</b>`');
with
var string = "Nullam|lingula|in";
var pattern = new RegExp (string, "ig");
var a=text.replace(pattern ,'`<b>$1</b>`');
This should gives out the same result, but it doesn’t. Any thoughts?
Thank you
You’re missing parens in your later statement, so there are no captures. And the flag is
gi, notig(although I’m not sure if this makes any difference)