Baseline Widely available
The flags
accessor property of RegExp
instances returns the flags of this regular expression.
// Outputs RegExp flags in alphabetical order
console.log(/foo/gi.flags);
// Expected output: "gi"
console.log(/^bar/muy.flags);
// Expected output: "muy"
Description
RegExp.prototype.flags
has a string as its value. Flags in the flags
property are sorted alphabetically (from left to right, e.g., "dgimsuvy"
). It actually invokes the other flag accessors (hasIndices
, global
, etc.) one-by-one and concatenates the results.
All built-in functions read the flags
property instead of reading individual flag accessors.
The set accessor of flags
is undefined
. You cannot change this property directly.
/foo/ig.flags; // "gi"
/^bar/myu.flags; // "muy"
Specifications Browser compatibility See also
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4