Created
August 22, 2013 16:10
-
-
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?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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