Introduction to Regular Expressions

As a JavaScript programmer, you will never absolutely have to use regular expressions. JavaScript functions you already know like indexOf() and lastIndexOf() can be cajoled to reach the same results. However, using regular expressions is usually much, much easier and faster. The ability to create regular expressions is a powerful tool in your toolbox.

So what are these regular expressions? Essentially, they're strings that define a certain pattern of text characters. However, they also have properties, so while regular expressions look a lot like strings, they're technically objects, with properties and methods attached to them.

In other words, regular expressions are sequences of regular and special characters, ...

Get Advanced JavaScript™: Insights and Innovative Techniques now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.