Regular Expressions 101

Sponso⁠rs

Community Library

Community Library Entry

0

Regular ExpressionOpen Workspace

/
([\s\[\{,:]+)(?!\-?\.?\d|false\W|true\W)([^'\":,\s\]\}]+)([:\s,\}\]_\-\{\[]|$)
/
g

Description
Created·2018-05-10 07:04
Type·Substitution
Flavor·PCRE (Legacy)

Add single quotes to unquoted parts of a valid JS hash so it can be parsed with JSON decoders. Tries to keep boolean and numeric values unquoted

Note: It will not handle certain edge-cases You might need to clear the trailing commas

Submitted by Anonymous
Open Workspace