Regular Expressions Explained in One Page
The Google Tech Lead YouTuber, whom I personally admire, once uploaded a video about several essential skills every developer should know:
- Regular Expressions
- SQL
- Debugging Skills (Problem Solving)
- Tooling Language
- Anti-Social Skill
Among these, today’s topic is Regular Expressions, mentioned first. Number 5 seems like a bit of an outlier; I believe developers communicate more than they code, so it might not be the best strategy. Even during my undergraduate years, I often noted down “study Regular Expressions later,” but I never truly memorized them, always looking them up when needed. I recently organized them, and it turns out they’re easier to remember when categorized like grammar rules. Indeed, as the Tech Lead mentioned, Regex is widely used in development. It’s used for text searching, or more precisely, pattern matching, and has numerous use cases such as:
- Log/text analysis via
grep - Searching code/directories you are developing
- Pre-commit code checking
- Web crawling
- URL parsing
- Value/format validation
Regex often appears like a cipher or an alien language before you study it. This is because while common languages express semantics through words or their combinations, Regex maps semantics to individual characters, similar to a cryptographic system. However, classifying its syntax as shown below greatly aids in mastering regular expressions.

Fundamentally, Regular Expressions are used to search for specific words. While there’s a method to 1. explicitly specify a particular word you want to find, you can also 2. specify words as combinations of characters or numbers. Regular Expressions provide both approaches.
Basic Syntax
You can simply specify the exact word you want to search for.
If you want to search for multiple words at once, you can include several words within parentheses () separated by |.
Character Sets
To specify particular characters, you can use a similar approach to specifying words, but [] allows you to find multiple characters, and within [], you can add rules for ranges like A to Z (A-Z) or exclude specific characters.
Character Types
If you want to search for numeric characters, [0-9] is good, as learned above, but you can also specify a ‘numeric’ character type. The backslash \ is used to specify character types. For example, the ‘numeric’ character type can be expressed as \d, and the ‘non-numeric’ character type can be indicated with a capital \D.
Advanced Syntax
Anchors (Positions)
Used when you want to find a specific word or character only if it appears at the very beginning or very end of a string/line.
Quantifiers (Repetition)
You can specify how many times a particular word or character should be repeated for a match.
(abc){1} = abc (exactly one occurrence)
(abc){1,3} = abc, abcabc, abcabcabc (one to three occurrences)
(abc)? = (empty string), abc (zero or one occurrence)
(abc)+ = abc, abcabc … (one or more occurrences)
Capturing = Grouping
As explained earlier, it’s used to group words for pattern searching or to save matched results when you intend to use those results.
Once learned, regular expressions are universally applicable across all programming languages and environments, offering immense utility due to the vast number of use cases in development. By organizing it this way, I should now be able to use it effectively without having to look it up every time.