Fix regexes to match brackets correctly. Modify test spec to ensure that rule
does not match mismatched brackets.