Very simple little question, but I don't quite understand how to do it.
I need to replace every instance of '_' with a space, and every instance of '#' with nothing/empty.
var string = '#Please send_an_information_pack_to_the_following_address:';
I've tried this:
string.replace('#','').replace('_', ' ');
I don't really chaining commands like this, but is there another way to do it in one?
Please try:
replace multi string
var str = "http://www.abc.xyz.com"; str = str.replace(/http:|www|.com/g, ''); //str is "//.abc.xyz"
replace multi chars
var str = "a.b.c.d,e,f,g,h"; str = str.replace(/[.,]/g, ''); //str is "abcdefgh";
Good luck!
You can just try this :
this will replace .,- and # with your replacechar !
I don't know if how much this will help but I wanted to remove
<b>
and</b>
from my stringso I used
so basically if you want a limited number of character to be reduced and don't waste time this will be useful.
Here's a simple way to do it without RegEx.
You can prototype and/or cache things as desired.
yourstring = '#Please send_an_information_pack_to_the_following_address:';
replace '#' with '' and replace '_' with a space
newstring2 is your result