Regular Expressions

Get a brief introduction to Regular Expressions and their importance in JavaScript.

The previous validations were quite primitive as many strings containing a @ character are not valid email addresses. To perform more advanced checks, you can use a powerful tool: regular expressions.

A regular expression defines a pattern to which strings are compared, searching for matches. Many programming languages support them. What follows is just an introduction to the vast domain of regular expression.

Let’s get started by trying to create a regular expression checking for the presence of an @ character inside a string. Here’s the associated JavaScript code.

Get hands-on with 1200+ tech skills courses.