JS: RegExp.prototype
What is RegExp.prototype
RegExp.prototype is the value of the property key "prototype" of the function RegExp.
console.assert(Object.hasOwn(RegExp, "prototype") === true);
Type
Type of RegExp.prototype is Object
.
console.assert(typeof RegExp.prototype === "object");
Parent
Parent of RegExp.prototype is Object.prototype
.
console.assert(Reflect.getPrototypeOf(RegExp.prototype) === Object.prototype);
Purpose
Purpose of RegExp.prototype is to provide methods and properties useful for all regexp instances.
RegExp.prototype is the parent of all RegExp instances.
console.assert(Reflect.getPrototypeOf(/abc/) === RegExp.prototype);
Properties
Function Properties
- RegExp.prototype.test
- RegExp.prototype.exec
RegExp.prototype.toStringRegExp.prototype[Symbol.match]JS2015RegExp.prototype[Symbol.replace]JS2015RegExp.prototype[Symbol.search]JS2015RegExp.prototype[Symbol.split]JS2015
Value Properties
RegExp.prototype.source-
Value is the regex pattern as string.
const xre = /[aeiou]/g; console.log("something".match(xre)); // [ "o", "e", "i" ] console.log(xre.source); // [aeiou] RegExp.prototype.flags-
(new in ECMAScript 2015)
A string of all regex flags that are on. e.g.
"gim"const xre = /[aeiou]/gi; console.log("SOMETHING".match(xre)); // [ "O", "E", "I" ] console.log(xre.flags); // gi
RegExp.prototype.lastIndex
Regex flags
These are boolean values corresponding to presence of regex flag in a regex object.
RegExp.prototype.globalRegExp.prototype.ignoreCaseRegExp.prototype.multilineRegExp.prototype.unicodeRegExp.prototype.sticky
JavaScript. Regular Expression
- JS: Regular Expression Tutorial
- JS: Regular Expression Functions
- JS: Create Regex Object
- JS: Regular Expression Syntax
- JS: Regular Expression Flags
- JS: Regex Replace String Dollar Sign
- JS: Regex Replace Function Args
- JS: RegExp (class)
- JS: RegExp Constructor
- JS: RegExp.prototype
- JS: String.prototype.search
- JS: String.prototype.match
- JS: String.prototype.matchAll
- JS: String.prototype.replace
- JS: String.prototype.replaceAll
- JS: RegExp.prototype.test
- JS: RegExp.prototype.exec