擅长:python、mysql、java
<p>这个问题的公认答案只考虑颜色和字体效果。有很多序列没有以m结尾,例如光标定位、擦除和滚动区域。</p>
<p>控制序列(也称为ANSI转义序列)的完整regexp是</p>
<pre><code>/(\x9B|\x1B\[)[0-?]*[ -\/]*[@-~]/
</code></pre>
<p>参考<a href="http://www.ecma-international.org/publications/files/ECMA-ST/Ecma-048.pdf">ECMA-48 Section 5.4</a>和<a href="https://en.wikipedia.org/wiki/ANSI_escape_code#CSI_codes">ANSI escape code</a></p>