While processing the input/output of a process created with
Usually ANSI codes are introduced by an ESC (
\x1b), an open square bracket, then numbers (possibly repeated:
*[32;40m) and terminated by a letter.
You can use something like
preg_replace them all to oblivion.
This works (just tested), even if definitely overkill:
$test = preg_replace('#\\x1b[[^A-Za-z]*[A-Za-z]#', '', $test);