Skip to content

Instantly share code, notes, and snippets.

View acst52's full-sized avatar

Ash acst52

View GitHub Profile
@acst52
acst52 / hex-regex-tutorial.md
Last active April 27, 2023 14:20
Unravelling the vibrant world of hex colors: a tutorial to decode their mysterious patterns

Understanding and Breaking Down a Hex Value Regular Expression (Regex)

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.

Hex Value Colors

Summary

This GitHub Gist decodes the regex used for matching a hex value: