RegExp.prototype.flags

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.

The flags accessor property of RegExp instances returns the flags of this regular expression.

Try it

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.

Examples

Using flags

js
/foo/ig.flags; // "gi"
/bar/myu.flags; // "muy"

Specifications

Specification
ECMAScript Language Specification
# sec-get-regexp.prototype.flags

Browser compatibility

Report problems with this compatibility data on GitHub
desktopmobileserver
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
Deno
Node.js
flags

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support

See also