RegExp()

JavaScript 1.2+, Jscript 3.0+ Nav4+, NES3+, IE4+ Syntax

var variable = new RegExp(pattern,
							flags)

Description

The RegExp() object represents a regular expression that is used for pattern matching. The creation of the object takes pattern and flags parameters. The pattern is a valid regular expression. The flags are either or both g (global) and i (ignore case). Table 6.32 displays the properties and methods of the RegExp() object.

Table 6.32. Properties and Methods of the RegExp() Object
Property/Method Description
RegExp.$* Represents multiline
RegExp.$& Represents lastmatch
RegExp.$_ Represents input
RegExp.$` Represents leftContext
RegExp.$' Represents rightContext
RegExp.$+ Represents lastParen
RegExp.$1,$2,…$9 ...

Get Pure JavaScript now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.