Get to know MDN better
This feature is well established and works across many devices and browser versions. It’s been available across browsers since January 2020.
The flags accessor property of RegExp instances returns the flags of this regular expression.
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.
| ECMAScript® 2027 Language Specification # sec-get-regexp.prototype.flags |
Enable JavaScript to view this browser compatibility table.
This page was last modified on Jul 10, 2025 by MDN contributors.
Your blueprint for a better internet.
Visit Mozilla Corporation’s not-for-profit parent, the Mozilla Foundation.
Portions of this content are ©1998–2026 by individual mozilla.org contributors. Content available under a Creative Commons license.