...

/

Dynamic Regular Expressions

Dynamic Regular Expressions

Challenge yourself with an example that uses the RegExp object to create dynamic regular expressions to solve the problem provided in this lesson.

Benefit of strings with RegExp objects

What is the point of having an entire object dedicated to defining and using a regular expression when the literal notation alternative exists? Is this another one of those crazy quirks from JavaScript?

Actually, no, it isn’t, and we’ll explain why. The literal notation for regular expressions works great, and it is usually the one we prefer when it comes to using them. You’re probably thinking: Then why the heck did they add an alternative to what is already perfect? That is a very ...