# by Artyom Bologov H # Remove all the non-bracket chars g/.*/s/[^][]//gp # Repeatedly remove all the simple matching brackets. # Add more lines to handle deeper nested expressions. g/\[\]/s///g g/\[\]/s///g g/\[\]/s///g g/\[\]/s///g g/\[\]/s///g g/\[\]/s///g g/\[\]/s///g g/\[\]/s///g g/\[\]/s///g g/\[\]/s///g g/\[\]/s///g g/\[\]/s///g g/\[\]/s///g g/\[\]/s///g g/\[\]/s///g g/./s/.*/Not balanced!/ g/^$/s/.*/Balanced!/ ,p Q