Reputation: 235
I am using the following function to replace '
in a string with
''
for ex
yourstring= "uncle Tom's cabin";
var crucial = yourstring.replace(/'/g, "''");
This does not work and I am not sure why!
Upvotes: 0
Views: 66
Reputation: 70523
Try this:
var yourstring = "uncle Tom's cabin";
var crucial = yourstring.replace("'","''");
This will only replace one '
Upvotes: 0
Reputation: 1169
Your code works, you only misspelled "your string" variable.
yourstring= "uncle Tom's cabin";
var crucial = yourstring.replace(/'/g, "''");
Upvotes: 2