RegExp.constructor

The RegExp constructor creates a regular expression object for matching text with a pattern.

Syntax

new RegExp(pattern, flags?)

Parameters

Return value

A new RegExp object.

Examples

(new RegExp("\\d+", "g")).test("123")
true
/\d+/g.test("123")
true