Opens in a new tab
A picture of Jeff Brigman
I CODE TODAY FOR
A BETTER TOMORROW

Glossary Term

RegExp() constructor

2 tags 1 category

For an introduction to regular expressions, read the Regular Expressions chapter in the JavaScript Guide.

Return value: RegExp(pattern) returns pattern directly if all of the following are true:

Return value: RegExp() is called without new; pattern is a regex; pattern.constructor === RegExp (usually meaning it’s not a subclass); flags is undefined.

Return value: In all other cases, calling RegExp() with or without new both create a new RegExp object. If pattern is a regex, the new object’s source is pattern.source; otherwise, its source is pattern coerced to a string. If the flags parameter is not undefined, the new object’s flags is the parameter’s value; otherwise, its flags is pattern.flags (if pattern is a regex).

Syntax example: new RegExp(pattern)

Term Connections

Explore related terms connected by shared tags, shared categories, and relationship phrases. This map loads only when it comes into view.

Loading term connections…