Regexes: The Introductory Lesson

Ever heard of the term regex? What about grep? They both represent the same basic premise: Regular Expressions. (Side note: grep is the Unix tool that can run Regular Expressions)

A Regular Expression (or regex) is a set of characters representing a text pattern. At its simplest, abc is a regex. When applied to the text


it matches the text in red, just like a normal search would in your text editor of choice. That’s because we were only dealing with literal, or non-special, characters. The special characters, however, are what makes regexes so powerful.

Special characters hold meaning outside of just the character itself. For example, the dot character represents a wildcard instead of a period, and the ? means the character before it is optional. There are a bunch of special characters, and they dramatically expand your ability to search through text. Let’s look at some examples…

Continue reading “Regexes: The Introductory Lesson”