Introduction
This lesson describes the series of exercises created for you that will help you understand and practice regular expressions.
We'll cover the following
By now, you have all the tools you need to understand how regular expressions work. You know how to write them, and you understand (or at least you have a reference to) all the strange symbols found inside one. However, using them requires something extra. Just like with any new tool, you also need to understand when it’s a good idea to use it and when using it might be something of an equivalent of using a bazooka to kill a fly.
Exercises
So, in this chapter, we will go over a series of exercises designed to teach you to use the tools from the previous chapter for the following tasks:
-
Dynamic search
This one is the easiest one to understand and visualize since we covered it quite extensively during the last chapter. Here, however, we’ll show you how to do it directly in JavaScript.
-
Smart replacement
Remember how we mentioned capturing groups before? Well, here we’ll show you how to use them to perform some interesting search and replacement tasks.
-
Validation
A variation of the dynamic search use case where you can mix somewhat complex regular expressions with the correct amount of JavaScript and perform data (i.e., user input) validation.
By the end of this chapter, our hope is that you’ll be able to start writing your own RegExps in your code (at least for the most basic use cases). We’ll get to the more complex ones in the next and final chapter.
Get hands-on with 1400+ tech skills courses.