Copy link to clipboard
Copied
When I change the double quotes in the following code to single quotes, I get an error
before change
script = script.replace(/\"/g, "'");
after change
script = script.replace(/'/g, '\'');
How do I change to single quotes in the correct style
Hi,
What do you want to achieve with this regular expression?
If you want to replace all single quotes with double quotes, here's how:
script = script.replace(/'/g, '"')
Copy link to clipboard
Copied
Hi,
What do you want to achieve with this regular expression?
If you want to replace all single quotes with double quotes, here's how:
script = script.replace(/'/g, '"')
Copy link to clipboard
Copied
I just want to add a little bit. If you want to change all the characters in a string, then instead of replace() you can use .split("").join("")
Example:
script = script.replace(/'/g, '"')
script = script.split("'").join('"')
Copy link to clipboard
Copied