Skip to content

Instantly share code, notes, and snippets.

View warrenp11's full-sized avatar

Peter warrenp11

View GitHub Profile
@warrenp11
warrenp11 / hexadecimal-regex.md
Last active September 26, 2022 10:57
Hexadecimal Color Code Validation Using Regular Expression

Regex Tutorial: Validating a Hexadecimal Color Code

The following documentation will attempt to explain the components of regular expressions (regex) and how they are used for many purposes, one of which is to validate a hexadecimal color code.

Summary

The following regex is used when validating a hexadecimal color code:

    /^#?([0-9a-f]{6}|[0-9a-f]{3})$/i