Regular Expressions 101

Add quotes to a malformed JSON string

Open Workspace
  • JavaScript
  • Substitution
0

Regular Expression

/
(")?([^{:"]+)(")?(: )(")?([^,}"]+)(")?(, |}+)
/
g

Description

This Regex allows to add double-quotes to a JSON string that is missing them. It assumes we have a space after the ":" and also after the ",".

Submitted by Anonymous