How can I perform a str_replace in JavaScript, replacing text in JavaScript?

后端 未结 22 1880
没有蜡笔的小新
没有蜡笔的小新 2020-12-01 00:29

I want to use str_replace or its similar alternative to replace some text in JavaScript.

var text = \"this is some sample text that i want to re         


        
22条回答
  •  孤独总比滥情好
    2020-12-01 01:15

    that function replaces only one occurrence.. if you need to replace multiple occurrences you should try this function: http://phpjs.org/functions/str_replace:527

    Not necessarily. see the Hans Kesting answer:

    city_name = city_name.replace(/ /gi,'_');
    

提交回复
热议问题