bhylu.com

Advertisements

JS RegExp Flags

Flags change matching behaviour. The i flag ignores letter case and g searches for repeated matches.

Where to run this

This example uses the JavaScript console playground. Select Run to execute it; the example does not run on this lesson page.

A practical example

JavaScript

const note = "Club club CLUB";
console.log(note.match(/club/gi));

What happens

All three differently cased words are matched.