I want to use str_replace or its similar alternative to replace some text in JavaScript.
str_replace
var text = \"this is some sample text that i want to re
More simply:
city_name=city_name.replace(/ /gi,'_');
Replaces all spaces with '_'!