Supported Versions: PHP 4, PHP 5, PHP 7, PHP 8
Perform a regular expression match
<?php preg_match(    string $pattern,    string $subject,    array &$matches = null,    int $flags = 0,    int $offset = 0): int|false
<?php         $rgbaPattern = '/^rgba ?\(([0-9]{1,3}), ?([0-9]{1,3}), ?([0-9]{1,3}), ?([0-9.]{1,4})\)$/i';



        if (preg_match($hexPattern, $value, $matches)) {

            $result = [];

            $result[0] = strlen($matches[1]) == '1' ? hexdec($matches[1].$matches[1]) : hexdec($matches[1]);

            $result[1] = strlen($matches[2]) == '1' ? hexdec($matches[2].$matches[2]) : hexdec($matches[2]);
<?php             $result[1] = strlen($matches[2]) == '1' ? hexdec($matches[2].$matches[2]) : hexdec($matches[2]);

            $result[2] = strlen($matches[3]) == '1' ? hexdec($matches[3].$matches[3]) : hexdec($matches[3]);

            $result[3] = 1;

        } elseif (preg_match($rgbPattern, $value, $matches)) {

            $result = [];

            $result[0] = ($matches[1] >= 0 && $matches[1] <= 255) ? intval($matches[1]) : 0;

            $result[1] = ($matches[2] >= 0 && $matches[2] <= 255) ? intval($matches[2]) : 0;
<?php             $result[1] = ($matches[2] >= 0 && $matches[2] <= 255) ? intval($matches[2]) : 0;

            $result[2] = ($matches[3] >= 0 && $matches[3] <= 255) ? intval($matches[3]) : 0;

            $result[3] = 1;

        } elseif (preg_match($rgbaPattern, $value, $matches)) {

            $result = [];

            $result[0] = ($matches[1] >= 0 && $matches[1] <= 255) ? intval($matches[1]) : 0;

            $result[1] = ($matches[2] >= 0 && $matches[2] <= 255) ? intval($matches[2]) : 0;
<?php         }



        $pattern = "/^data:(?:image\/[a-zA-Z\-\.]+)(?:charset=\".+\")?;base64,(?P<data>.+)$/";

        preg_match($pattern, str_replace(["\n", "\r"], '', $data_url), $matches);



        if (is_array($matches) && array_key_exists('data', $matches)) {

            return base64_decode($matches['data']);
<?php     public function getCommandName()

    {

        preg_match("/\\\\([\w]+)Command$/", get_class($this->command), $matches);

        return isset($matches[1]) ? lcfirst($matches[1]).'()' : 'Method';

    }