I'm trying to convert this:
\/\*[^*\/]*(?:(?!\/\*|\*\/)[*\/][^*\/]*)*\*\/g
This is a nested Regex that works perfectly
/* one */
Stuff one
/* two /* three */
two */
Stuff two
/* four */
Into something like this:
a: {[^\}]*(?:(?!a: {|\})[\}][^\}]*)*\}g
(Does not work properly)
I have been trying to get this to work for days now… no luck.
a: { one }
Stuff one
a: { two a: { three }
two }
Stuff two
a: { four }
How it's suppose to work
source = "/* one */ Stuff one /* two /* three */ two */ Stuff two /* four */"
regex = /\/\*[^*\/]*(?:(?!\/\*|\*\/)[*\/][^*\/]*)*\*\//g
results = source.match(regex)
$("body").append("<pre>" + JSON.stringify(results, null, 2) + "</pre>")
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
What I've done
source = "a: { one } Stuff one a: { two a: { three } two } Stuff two a: { four }"
regex = /a: {[^\}]*(?:(?!a: {|\})[\}][^\}]*)*\}/g
results = source.match(regex)
$("body").append("<pre>" + JSON.stringify(results, null, 2) + "</pre>")
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
What I've done… is showing this:
a: { one }
Stuff one
a: { two a: { three }
two }
Stuff two
a: { four }
But it should be this
a: { one }
Stuff one
a: { two a: { three }
two }
Stuff two
a: { four }