Sample Header Ad - 728x90

how to detect unbalanced special characters in string

0 votes
1 answer
254 views
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:
bqM#+t1U"OyBGhk]ozVG[v"&
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:
i],U2y.2y[A~a`^[
Asked by irishwristwatch (1 rep)
Nov 16, 2022, 09:46 PM
Last activity: Nov 17, 2022, 03:51 PM