I'm attempting to replace a string with another string in Javascript and using the answer given in How do you use a variable in a regular expression? by Eric Wendelin - code is the following:
var re = new RegExp(delim, 'g');
return input.replace(re,",");
When i run this i get the error
/***/: Nothing to repeat
(the value of delim is "***" btw)
I understand if you get a Nothing to repeat error it means you haven't properly escaped a character in your regexp but why do i get this error in this case ?