Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

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

Explorer ,
Apr 28, 2023 Apr 28, 2023

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

TOPICS
ActionScript , Error , How to
852
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Engaged , Apr 28, 2023 Apr 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, '"')

 

 

 

Translate
Engaged ,
Apr 28, 2023 Apr 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 1998
Member of Flanimate Power Tools team - extensions for character animation
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Apr 28, 2023 Apr 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('"') 

 

 

 

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 28, 2023 Apr 28, 2023
LATEST

@Multoman 

 

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines