RegExp JavaScript or Regular Expressions js

RegExp is an Object

A RegExp is some object that can describe a pattern of characters.

Regular expressions you can use to perform pattern-matching and “search-and-replace” functions on string.

RegExp’s JavaScript syntax


A regular expression is a sequence of characters that forms a search pattern.

How to use String search() With a Regular Expression

You can use a regular expression to do a search for “sga” in a string:

    var str = "Visit - web programming site!"; 
    var res =;
    console.log(res); // 6 - position of searched text

Leave a Reply