castaway's list is no substitute for a specification of ANSI escapes, and her resulting regex suffers from the same problem as yours, although they break on opposite cases: neither takes into account that you can put any number of colours (including just one) in the same escape sequence by separating them with a semicolon. Yours will also match more than just escape sequences. Use