Skip to main content
Chaint
Known Participant
April 28, 2023
Answered

A JavaScript error occurred. SyntaxError: missing } after property list

  • April 28, 2023
  • 2 replies
  • 868 views

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

This topic has been closed for replies.
Correct answer Vladin M. Mitov

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, '"')

 

 

 

2 replies

Multoman
Inspiring
April 28, 2023

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('"') 

 

 

 

 

kglad
Community Expert
Community Expert
April 28, 2023

@Multoman 

 

that should be split("originalcharacter").join("replacementcharacter")

Vladin M. Mitov
Vladin M. MitovCorrect answer
Inspiring
April 28, 2023

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, '"')

 

 

 

- Vlad: UX and graphic design, Flash user since 1998Member of Flanimate Power Tools team - extensions for character animation