How to validate if code blocks, as in a construct:
{
// Any amount of characters that aren't '{' or '}'
}
Are properly nested, preferably with regex?
{} {
{} {}
} // Properly nested
{{
{{}}
} {} // Not properly nested
As referred to from this thread, approaches such as recursion and balancing groups cannot apply here, as the regular expression constructs are not present in Java Pattern.
String
. Is there a way to use a stack in this situation?