rototype.__proto__ ` ](/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/proto) Deprecated 
  13. Methods 
    1. [ ` Object.prototype.__defineGetter__() ` ](/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/__defineGetter__) Deprecated 
    2. [ ` Object.prototype.__defineSetter__() ` ](/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/__defineSetter__) Deprecated 
    3. [ ` Object.prototype.__lookupGetter__() ` ](/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/__lookupGetter__) Deprecated 
    4. [ ` Object.prototype.__lookupSetter__() ` ](/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/__lookupSetter__) Deprecated 
    5. [ ` Object.prototype.hasOwnProperty() ` ](/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/hasOwnProperty)
    6. [ ` Object.prototype.isPrototypeOf() ` ](/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/isPrototypeOf)
    7. [ ` Object.prototype.propertyIsEnumerable() ` ](/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/propertyIsEnumerable)
    8. [ ` Object.prototype.toLocaleString() ` ](/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/toLocaleString)
    9. [ ` Object.prototype.toString() ` ](/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/toString)
    10. [ ` Object.prototype.valueOf() ` ](/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/valueOf)

##  In this article

  * Description 
  * Constructor 
  * Static properties 
  * Instance properties 
  * Instance methods 
  * Examples 
  * Specifications 
  * Browser compatibility 
  * See also 

#  RegExp

The **` RegExp ` ** object is used for matching text with a pattern.

For an introduction to regular expressions, read the [ Regular expressions
chapter ](/en-US/docs/Web/JavaScript/Guide/Regular_expressions) in the
JavaScript guide. For detailed information of regular expression syntax, read
the [ regular expression reference ](/en-
US/docs/Web/JavaScript/Reference/Regular_expressions) .

##  Description

###  Literal notation and constructor

There are two ways to create a ` RegExp ` object: a _literal notation_ and a
_constructor_ .

  * The _literal notation_ takes a pattern between two slashes, followed by optional [ flags ](/en-US/docs/Web/JavaScript/Guide/Regular_expressions#advanced_searching_with_flags) , after the second slash. 
  * The _constructor function_ takes either a string or a ` RegExp ` object as its first parameter and a string of optional [ flags ](/en-US/docs/Web/JavaScript/Guide/Regular_expressions#advanced_searching_with_flags) as its second parameter. 

The following three expressions create the same regular expression object:

js

    
    
    const re = /ab+c/i; // literal notation
    // OR
    const re = new RegExp("ab+c", "i"); // constructor with string pattern as first argument
    // OR
    const re = new RegExp(/ab+c/, "i"); // constructor with regular expression literal as first argument
    

Before regular expressions can be used, they have to be compiled. This process
allows them to perform matches more efficiently. More about the process can be
found in [ dotnet docs ](https://docs.microsoft.com/dotnet/standard/base-
types/compilation-and-reuse-in-regular-expressions) .

The literal notation results in compilation of the regular expression when the
expression is evaluated. On the other hand, the constructor of the ` RegExp `
object, ` new RegExp('ab+c') ` , results in runtime compilation of the regular
expression.

Use a string as the first argument to the ` RegExp() ` constructor when you
want to  build the regular expression from dynamic input  .

###  Flags in constructor

The expression ` new RegExp(/ab+c/, flags) ` will create a new ` RegExp `
using the source of the first parameter and the [ flags ](/en-
US/docs/Web/JavaScript/Guide/Regular_expressions#advanced_searching_with_flags)
provided by the second.

When using the constructor function, the normal string escape rules (preceding
special c