In this tutorial we'll be explaining the regex used to match a hex value. Hex values, which are short for hexadecimal values, represent colors in web development and design. Hex values are a base-16 numeral system, and the colors they represent consist of a combination of 3 or 6 characters, often starting with a #
symbol. Let's explore when and where this hex regex is used, get into each part of it, and describe its functionality so we can all understand how it matches hex values and where we can apply the regular expression.
This GitHub Gist decodes the regex used for matching a hex value: