I am looking for a Regex that allows me to validate json.
I am very new to Regex\'s and i know enough that parsing with Regex is bad but can it be used to validate?
I created a Ruby implementation of Mario's solution, which does work:
# encoding: utf-8
module Constants
JSON_VALIDATOR_RE = /(
# define subtypes and build up the json syntax, BNF-grammar-style
# The {0} is a hack to simply define them as named groups here but not match on them yet
# I added some atomic grouping to prevent catastrophic backtracking on invalid inputs
(? -?(?=[1-9]|0(?!\d))\d+(\.\d+)?([eE][+-]?\d+)?){0}
(? true | false | null ){0}
(? " (?>[^"\\\\]* | \\\\ ["\\\\bfnrt\/] | \\\\ u [0-9a-f]{4} )* " ){0}
(? \[ (?> \g (?: , \g )* )? \s* \] ){0}
(? \s* \g \s* : \g ){0}
(?