Supported Versions: PHP 4, PHP 5, PHP 7, PHP 8
Perform a regular expression search and replace
preg_replace(    string|array $pattern,    string|array $replacement,    string|array $subject,    int $limit = -1,    int &$count null): string|array|null
            for ($i=0$i $charsCount$i++) {



                if (
$i == 0) {

                    
$result .= preg_replace($colorsTags$colorsValues$this->styles->get('font.buffer.' $j));

                }



                
$result .=  preg_replace($colorsTags$colorsValues$chars[$i][$j]) . 
                    $result .= preg_replace($colorsTags$colorsValues$this->styles->get('font.buffer.' $j));

                }



                
$result .=  preg_replace($colorsTags$colorsValues$chars[$i][$j]) . 

                            
strings(preg_replace($colorsTags$colorsValues$this->styles->get('font.letterspace.' $j)))->repeat(($letterSpacing 1) ? $letterSpacing 1);

                

                if (
$i == $charsCount 1) {
                }



                
$result .=  preg_replace($colorsTags$colorsValues$chars[$i][$j]) . 

                            
strings(preg_replace($colorsTags$colorsValues$this->styles->get('font.letterspace.' $j)))->repeat(($letterSpacing 1) ? $letterSpacing 1);

                

                if (
$i == $charsCount 1) {

                    
$result .= preg_replace($colorsTags$colorsValues$this->styles->get('font.buffer.' $j));
                            strings(preg_replace($colorsTags$colorsValues$this->styles->get('font.letterspace.' $j)))->repeat(($letterSpacing 1) ? $letterSpacing 1);

                

                if (
$i == $charsCount 1) {

                    
$result .= preg_replace($colorsTags$colorsValues$this->styles->get('font.buffer.' $j));

                }

            }

            if (
$j $linesCount) {
    public function stripStyles(string $value): string

    
{

        return 
preg_replace("/" terminal()->getEsc() . "\[[^m]*m/"''$value);

    }