Learning the Basics of RegEx
A quick primer on what RegEx is and how you can use it in your JavaScript projects
When I was working on some algorithm problem sets a few days ago, I kept running into a pretty commonplace scenario when working with text — I found myself needing to extract information from a string to perform a specific set of operations on it.
While reformatting data is something most engineers deal with during their day to day, sifting through strings to extract data can complicate things quite a bit. Regular Expressions, commonly referred to as RegEx, make that process infinitely easier.
Let’s dive into what Regular Expressions are and how you can use them to manipulate data embedded in strings as necessary.
What Are Regular Expressions?
According to MDN, “Regular expressions are patterns used to match character combinations in strings.”
Regular expressions allow you to search for character combinations and output those matches for storage or to operate on them. This can be useful in several cases, including password matching, checking for valid email formatting, character replacement, and more.