Skip to content

Instantly share code, notes, and snippets.

REG-hEXed - A Tutorial

According to The Coding Train, a regular expression (regex) is defined as "a sequence of expressions that define a search pattern". What I hope to demonstrate in this exercise is how to use a given regex to seek out and recover a desired set of results and also to decipher for the user the meaning behind all the cryptic alphanumeric characters that comprise regular expressions.

This article will focus on hex values and how to use regex definitions to obtain desired search results.

Summary

In this tutorial, we are going to focus on using regular expressions to match hexadecimal values. Hexadecimal codes, often referred to simply as “hex codes”, are codes written in base-16 format. One application for these codes are in web design, where the Unpacking the values contained within the regex coding will explain various facets of the search, sectioned within the Table of Contents.

For this tutorial, we will examine the code `/^#?([A-F0-9