JS Built-ins
RegExpflagsbeginner

RegExp flags β€” no 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

A RegExp with no flags has an empty string for flags.

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

πŸ’‘ Hints (1)
  • β€’ If no flags are set, flags returns an empty string