Regular Expression to Color Code
Regular Expression:
To identify hexadecimal color value, We can use the following regular expression.
Example:
$color_given=”#A12F12″;
$color_pattern = “/^(#)?([0-9|A|B|C|D|E|F]{6})$/”;
if (preg_match($pattern,$color_given))
{
$color_code = true;
}
