ect/constructor)
    2. [ ` Object.prototype.__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

  * Try it 
  * Syntax 
  * Examples 
  * Specifications 
  * Browser compatibility 
  * See also 

#  RegExp() constructor

The **` RegExp() ` ** constructor creates [ ` RegExp ` ](/en-
US/docs/Web/JavaScript/Reference/Global_Objects/RegExp) objects.

For an introduction to regular expressions, read the [ Regular Expressions
chapter ](/en-US/docs/Web/JavaScript/Guide/Regular_expressions) in the [
JavaScript Guide ](/en-US/docs/Web/JavaScript/Guide) .

##  Try it

##  Syntax

js

    
    
    new RegExp(pattern)
    new RegExp(pattern, flags)
    RegExp(pattern)
    RegExp(pattern, flags)
    

**Note:** ` RegExp() ` can be called with or without [ ` new ` ](/en-
US/docs/Web/JavaScript/Reference/Operators/new) , but sometimes with different
effects. See  Return value  .

###  Parameters

` pattern `

    

The text of the regular expression. This can also be another ` RegExp `
object.

` flags ` Optional

    

If specified, ` flags ` is a string that contains the flags to add.
Alternatively, if a ` RegExp ` object is supplied for the ` pattern ` , the `
flags ` string will replace any of that object's flags (and ` lastIndex ` will
be reset to ` 0 ` ).

` flags ` may contain any combination of the following characters:

[ ` d ` (indices) ](/en-
US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/hasIndices)

    

Generate indices for substring matches.

[ ` g ` (global) ](/en-
US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/global)

    

Find all matches rather than stopping after the first match.

[ ` i ` (ignore case) ](/en-
US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/ignoreCase)

    

When matching, casing differences are ignored.

[ ` m ` (multiline) ](/en-
US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/multiline)

    

Treat beginning and end assertions ( ` ^ ` and ` $ ` ) as working over
multiple lines. In other words, match the beginning or end of _each_ line
(delimited by ` \n ` or ` \r ` ), not only the very beginning or end of the
whole input string.

[ ` s ` (dotAll) ](/en-
US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/dotAll)

    

Allows ` . ` to match newlines.

[ ` u ` (unicode) ](/en-
US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/unicode)

    

Treat ` pattern ` as a sequence of Unicode code points.

[ ` v ` (unicodeSets) ](/en-
US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/unicodeSets)

    

An upgrade to the ` u ` flag that enables set notation in character classes as
well as properties of strings.

[ ` y ` (sti