I'm wondering what would be the best way (likely using grep or ack) to return lines containing unbalanced special character sets in a string? For example, if the string were:
and the specified character were a double-quote ("), this line would not be returned. However, what I'm looking for is more complicated, requiring a left and right balance, for instance a left square parenthesis ([) and a right square parenthesis (]). Then the line would be returned if the number of ([) does not equal the number of (]) such as:
”and 0 to 5 sets of
) If so, you can do it with a long and complicated regex. Otherwise you will need to write a custom program to count each and verify.
 ] [ balanced? i.e do you need a
]to be preceded by its corresponding
[or just the number of
[s to be the same as the number of