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.
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]