Skip to content

Instantly share code, notes, and snippets.

@willread
Created August 22, 2013 16:10
Show Gist options
  • Save willread/6309319 to your computer and use it in GitHub Desktop.
Save willread/6309319 to your computer and use it in GitHub Desktop.
Regex to strip trailing commas from objects and arrays, because those are bad, mkay?
var s = "{ a: 0, b: [ 1, 2, 3, ], }";
s = s.replace(/\,(\s+)(\]|\})/g, "$1$2");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment