更新时间:2023-02-26 11:12:16
正则表达式不是适合该工作的工具.手动扫描字符串.
Regex is not the right tool for the job. Scan a string manually.
伪代码:
depth = 0
for character in some_string:
depth += character == '('
depth -= character == ')'
if depth < 0:
break
if depth != 0:
print "unmatched parentheses"