Regex For Parsing Object Literal
Im trying to parse out a JavaScript object literal from a script block on
a page. Here's the example I have of the data:
//End Update for CASE00370003 2011/08/22
stores[0] = {
'fullName' : 'Bobs Commons',
'street1' : '23 Chestnut Commons Dr'
};
//Some more comments
stores[1] = {
'fullName' : 'Gove Wood',
'street1' : '65 Lake Rd'
};
So far I've come up with:
/^(stores\[)(\d){1,2}(])(.|\n)*};$/m
However, the string ends with "};" will grab the last occurrence of the };
on stores[1], so each won't be broken individually. Thanks!
No comments:
Post a Comment