.replace() not working correctly
I have a string that i would like to convert.
the string is image and the content is: Gone in 60 seconds
What i need is the following: Gone_in_60_seconds
But when i try: image = image.replace(" ","_");
the result is: 开发者_如何学JAVAGone_in 60 seconds
so only the first space gets replaced.
How would i convert all the spaces to underscores?
Try this:
image = image.replace(/ /g, "_");
精彩评论