Introduction to JavaScript Regular Expressions


show more Regular expressions, which describe and can match patterns and strings, are built into JavaScript. Learn the basics principles of creating and applying regular expressions to find certain strings, including dates, zip codes, and email addresses. show less
please wait ...

Introduction to regular expressions

JavaScript, like many programming languages, if not all of them these days, has regular expressions built into the language. Now, regular expressions are odd-looking sequences of characters that describe and can match patterns and strings. They let you verify that a credit card number has the right amount of digits, or that an email address, or URL matches a basic pattern, or that a password has a mixture of uppercase and lowercase letters, or just define certain words in a larger string. Now nobody finds regular expressions pleasant to begin with, but they are very useful, and there is always two parts to them: first you create the regular expression that describes the pattern that you are looking for, and then you apply it to something else to see if it matches.

So step one, we describe the regular expression. We can create a variable in JavaScript. I've created one called myRE for my regular expression and set it equal to /hello/. This is almost like creating a string variable excep...

Introduction to regular expressions
Video duration: 6m 56s 5h 31m Beginner

Viewers:

Regular expressions, which describe and can match patterns and strings, are built into JavaScript. Learn the basics principles of creating and applying regular expressions to find certain strings, including dates, zip codes, and email addresses.

Subjects:
Developer Web
Software:
JavaScript
Author:
please wait ...