Check nesting of braces in a string