javascript - Replace method doesn't work -


i want replace smart quotes , , , regular quotes. also, wanted replace ©, ® , . used following code. doesn't help. kindly me resolve issue.

str.replace(/[“”]/g, '"'); str.replace(/[‘’]/g, "'"); 

use:

str = str.replace(/[“”]/g, '"'); str = str.replace(/[‘’]/g, "'"); 

or in 1 statement:

str = str.replace(/[“”]/g, '"').replace(/[‘’]/g,"'"); 

in javascript (as in many other languages) strings immutable - string "replacement" methods return new string instead of modifying string in place.

the mdn javascript reference entry replace states:

returns new string or matches of pattern replaced replacement.

this method not change string object called on. returns new string.


Comments

Popular posts from this blog

python Tkinter Capturing keyboard events save as one single string -

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

javascript - Z-index in d3.js -