Supported Versions: PHP 4, PHP 5, PHP 7, PHP 8
Perform a regular expression match
preg_match(    string $pattern,    string $subject,    array &$matches null,    int $flags 0,    int $offset 0): int|false
    public function convertRgbColorToHex(string $color): string

    
{

        if (
preg_match('/(\d{1,3})\,?\s?(\d{1,3})\,?\s?(\d{1,3})/'$color$matches)) {

            
$color sprintf('%02x%02x%02x'$matches[1], $matches[2], $matches[3]);

        }
    private function initDimensions(): void

    
{

        if (
DIRECTORY_SEPARATOR === '\\') {

            if (
preg_match('/^(\d+)x(\d+)(?: \((\d+)x(\d+)\))?$/'trim(getenv('ANSICON')), $matches)) {



                
self::$width  = (int) $matches[1];
            return;

        }



        if (
preg_match('/rows.(\d+);.columns.(\d+);/i'$sttyString$matches)) {


            
self::$width  = (int) $matches[2];

            
self::$height = (int) $matches[1];
            self::$width  = (int) $matches[2];

            
self::$height = (int) $matches[1];

        } elseif (
preg_match('/;.(\d+).rows;.(\d+).columns/i'$sttyString$matches)) {


            
self::$width  = (int) $matches[2];

            
self::$height = (int) $matches[1];
    {

        
$info $this->readFromProcess('mode CON');



        if (
$info === null || ! preg_match('/--------+\r?\n.+?(\d+)\r?\n.+?(\d+)\r?\n/'$info$matches)) {

            return 
null;

        }