I need to make a replace in a whole string with a format similar to the following:
var miRegExp = "^[0-9]+$";
var miString = $("input").val();
miString = miString.replace(new RegExp(miRegExp)+ /g, '');
The objective is to replace all the characters that are not supported in my string, in this case numbers, although I have other cases that I will use from this example to replace other patterns for chains such as mails, user names, etc.
The exposed example does not work and it throws an error but I put it so that it is understood what I want to achieve