擅长:python、mysql、java
<p>正则表达式是错误的工具,因为您正在处理嵌套结构,即递归。</p>
<p>但是有一个简单的算法可以做到这一点,我将<a href="https://stackoverflow.com/questions/524548/regular-expression-to-detect-semi-colon-terminated-c-for-while-loops/524624#524624">in this answer</a>描述为<a href="https://stackoverflow.com/questions/524548/regular-expression-to-detect-semi-colon-terminated-c-for-while-loops">previous question</a>。</p>