From the course: Learning the JavaScript Language

Unlock the full course today

Join today to access over 24,800 courses taught by industry experts.

Regular expressions

Regular expressions

- [Instructor] In this lesson, we're going to take a look at regular expressions, which are a way of searching text for patterns. When you're working with text like strings and JavaScript, but also if you're working with long runs of text in prose, there may be times when you want to find a particular something, but maybe not an exact something. Maybe you can describe it with a pattern that it should follow, like two digits followed by any number of letters, or any word that starts with A and ends with S. A regular expression is a way to describe something that you're searching for with an abstract pattern. In JavaScript, a regular expression is another data type just like numbers or strings, and it looks like this. Now, if we just have two slashes with nothing in between 'em, that is, of course, a line comment, but it becomes a regular expression when there's something in between those slashes. That can be words, it…

Contents