JS Built-ins
RegExpflagsbeginner

RegExp flags β€” gi flags

πŸ“– Usage Example
const re = /hello/gi
console.log(re.flags) // β†’ 'gi'

Read RegExp.flags to get a string of all active flags on the regular expression.

RegExp.prototype.flags

The flags property returns the flags of the RegExp sorted alphabetically.

Challenge: Verify that /hi/gi.flags equals 'gi'.

πŸ’‘ Hints (1)
  • β€’ flags are returned in alphabetical order