Regular Expressions 101

Community Patterns

Add quotes to a malformed JSON string

0

Regular Expression
ECMAScript (JavaScript)

/
(")?([^{:"]+)(")?(: )(")?([^,}"]+)(")?(, |}+)
/
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 - 10 months ago