Supported Versions: PHP 4, PHP 5, PHP 7, PHP 8
Perform a regular expression search and replace
<?php preg_replace(    string|array $pattern,    string|array $replacement,    string|array $subject,    int $limit = -1,    int &$count = null): string|array|null
<?php             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]) . 
<?php                     $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) {
<?php                 }



                $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));
<?php                             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 + 1 < $linesCount) {
<?php     public function stripStyles(string $value): string

    {

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

    }