Regular Expressions and String Methods
Introduction to the usage of RegEx with string methods, search and replace, in JavaScript.
We'll cover the following
We know what is RegEx and JavaScript object RegExp. In this lesson, we look at the practical aspect of a RegEx and see how it works with string methods.
Introduction
Regular expressions in JavaScript have methods to test and/or execute an expression on a string. It checks for any matching. RegEx, used in string methods, can make queries simpler. Let’s take a look at those methods and eventually do more complicated tasks.
search
method
The search
method is a string method that takes a query-string as an argument and searches within the string to return the character index at which the query-string starts. It returns “-1” if no match is found.
Get hands-on with 1400+ tech skills courses.