Replace multiple characters in one replace call

前端 未结 15 2524
失恋的感觉
失恋的感觉 2020-11-22 17:24

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 no

15条回答
  •  一生所求
    2020-11-22 17:38

    yourstring = '#Please send_an_information_pack_to_the_following_address:';

    replace '#' with '' and replace '_' with a space

    var newstring1 = yourstring.split('#').join('');
    var newstring2 = newstring1.split('_').join(' ');
    

    newstring2 is your result

提交回复
热议问题