Skip to content

Instantly share code, notes, and snippets.

@michelmany
Created May 24, 2022 17:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save michelmany/b8625bd9926cb1fc6d88b114e4a48d38 to your computer and use it in GitHub Desktop.
Save michelmany/b8625bd9926cb1fc6d88b114e4a48d38 to your computer and use it in GitHub Desktop.
JSON.parse remove invalid string caracter with regex
const newString = JSON.parse(str.replace(/(\{|,)\s*(.+?)\s*:/g, '$1 "$2":'))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment