Extract ANSI escape sequence to a function

This commit is contained in:
salehhashemi1992
2023-10-13 20:16:46 +03:30
parent b126e8e6e4
commit 86c107ae5e
7 changed files with 19 additions and 8 deletions

View File

@ -194,3 +194,16 @@ if (! function_exists('afterAll')) {
TestSuite::getInstance()->afterAll->set($closure);
}
}
if (! function_exists('removeAnsiEscapeSequences')) {
/**
* Remove ANSI escape sequences from a given string.
*
* @param string $input The string containing ANSI escape sequences.
* @return string|null A new string with all ANSI escape sequences removed.
*/
function removeAnsiEscapeSequences(string $input): ?string
{
return preg_replace('#\\x1b[[][^A-Za-z]*[A-Za-z]#', '', $input);
}
}