Skip to content

Instantly share code, notes, and snippets.

View HarrisSte's full-sized avatar
🔍
Seeking employment

Stephanie HarrisSte

🔍
Seeking employment
View GitHub Profile
@HarrisSte
HarrisSte / regexTutorial.md
Last active July 19, 2023 20:55
Regex Tutorial: Hex Values

Regex Tutorial: Hex Values

Regular expressions (regex) allow us to search more dynamically through documents. They are a sequence of characters that define a search pattern. While the search patterns can seem intimidating when you look at them as a whole, they are simple to understand when breaking them into manageable parts. This tutorial will describe each literal and meta character in a code snippet example and how regex functions when matching a Hex Value.

Summary

The regex this tutorial will explore is when you want to match a Hex Value. To understand how the code snippet works, we will break down each component both literal and meta characters, to help us understand how the regex works. The code snippet we will work through in this tutorial is: /^#?([a-f0-9]{6}|[a-f0-9]{3})$/

What are Hex Values? Hexadecimal values (Hex Values) are ways in which colors can be represented in computing and digital systems. They are often represented by a combination of letters [a-f] and numbers [0-9]