Skip to content

Instantly share code, notes, and snippets.

@Eric-JG
Eric-JG / Regex-Tutorial.md
Last active March 1, 2023 20:42
Computer Science for JavaScript Challenge: Regex Tutorial

Tutorial: Regex matching Hex value

Regular expressions are patterns used to match character combinations in strings. In a regular expression the metacharacter ^ means "not". So, while "a" means "match lowercase a", "^a" means "do not match lowercase a".

Summary

Today I will be covering and breaking down the components of a regular expression used to match Hex Values. Hexadecimal code is a system by which any specific color can be described accurately to a computer, ensuring consistency and accuracy in an electronic display. A hexadecimal color value is a six-digit code preceded by a # sign; it defines a color that is used in a website or a computer program. /^#?([a-f0-9]{6}|[a-f0-9]{3})$/

Table of Contents