.net regex balancing groups countenance - relating balanced


conduct explode. i've got twine i'm perplexing match:



other things blah blah....
{
things stuff
{key:
stuff
stuff
}
} some-more stuff.....


here's regex:



[^{}]*                      # anything isn't { }
\{ # starting {
(?> # atomic group: pitch divided backtracks exit
[^{}]+
|
\{(?:\w+:)?(?<depth>) # relating { and discretionary "word:" pull smoke-stack
|
\}(?<-depth>) # relating } cocktail stack
)*
(?(depth)(?!)) # abyss unbalanced, destroy match
\} # finale }
[^{}]* # anything isn't { }


so, i'm perplexing review balancing curly braces, where opening curly braces have an discretionary followed colon. above regex matches instance string, nonetheless i mislay curly brace, (i.e. "unbalancing it):



    things blah blah....
{
things stuff
{key:
stuff
stuff

} some-more stuff.....


...it still matches!



can anyone tell me repair regex?



Comments

Popular posts from this blog

list macos calm editors formula editors

how hibernate @any-related annotations?

why does floated <input> control floated component slip over too distant right ie7, nonetheless firefox?