Skip to content

Latest commit

 

History

History
74 lines (61 loc) · 3.46 KB

File metadata and controls

74 lines (61 loc) · 3.46 KB
title ms.custom ms.date ms.prod ms.reviewer ms.suite ms.technology ms.tgt_pltfrm ms.topic f1_keywords dev_langs helpviewer_keywords ms.assetid caps.latest.revision author ms.author manager
RegExp Object (JavaScript) | Microsoft Docs
01/18/2017
windows-client-threshold
devlang-javascript
language-reference
RegExp
JavaScript
TypeScript
DHTML
RegExp object, overview
RegExp object
7f6b1073-8cbb-49ed-94b6-56833ba663c5
12
mikejo5000
mikejo
ghogen

RegExp Object (JavaScript)

An intrinsic global object that stores information about the results of regular expression pattern matches.

Syntax

  
RegExp.property   

Remarks

The required property argument can be any one of the RegExp object properties.

The RegExp object cannot be created directly, but is always available for use. Until a successful regular expression search has been completed, the initial values of the various properties of the RegExp object are as follows:

Property Shorthand Initial Value
index -1
input $_ Empty string.
lastIndex -1
lastMatch $& Empty string.
lastParen $+ Empty string.
leftContext $` Empty string.
rightContext $' Empty string.
$1 - $9 $1 - $9 Empty string.

Its properties have undefined as their value until a successful regular expression search has been completed.

The global RegExp object should not be confused with the Regular Expression object. Even though they sound like the same thing, they are separate and distinct. The properties of the global RegExp object contain continually updated information about each match as it occurs, while the properties of the Regular Expression object contain only information about the matches that occur with that instance of the Regular Expression.

Example

The following example performs a regular expression search. It displays matches and submatches from the global RegExp object, and from the array that is returned by the exec method.

1

Properties

$1...$9 Properties | index Property | input Property | lastIndex Property | lastMatch Property | lastParen Property | leftContext Property | rightContext Property

Methods

The RegExp object has no methods.

Requirements

[!INCLUDEjsv3]

See Also

Regular Expression Object
Regular Expression Syntax (JavaScript)
String Object