I'm trying to replace all characters that are any of the following: !# in a javascript string (specifically a URL).
href = 'http://example.test/foo/bar#';
href = href.replace('/[\#\!]/g', '');
console.log('href', href);
But it doesn't seem to be performing the replacements, even though I tried the regex with various testers and it works with the string.
'/[\#\!]/g'=>/[\#\!]/g#and!are not special characters in Javascript regex, you don't have to escape them.