Fix finding matching "[" and "]"

Reported by rdebath. Thanks!