W3cubDocs

/JavaScript

RegExp.prototype.flags

The flags accessor property represents the flags of the current regular expression object.

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. "dgimsuy"). 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 flag is undefined. You cannot change this property directly.

Examples

Using flags

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

Specifications

Browser compatibility

Desktop Mobile Server
Chrome Edge Firefox Internet Explorer Opera Safari WebView Android Chrome Android Firefox for Android Opera Android Safari on IOS Samsung Internet Deno Node.js
flags
49
79
37
No
39
9
49
49
37
41
9
5.0
1.0
6.0.0

See also

© 2005–2022 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/flags