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.
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 sga.su - web programming site!"; var res = str.search(/w3Schools/i); console.log(res); // 6 - position of searched text