Skip to main content
Module 7 · Lesson 1 of 425/32 in the course~18 min
Module lessons (1/4)

All flags in detail

Lesson preview5 hands-on exercises readyRegex Course · Module 7 — Flags, substitution, split

g i m s u v y d: what each one does and how they combine.

What you'll learn in this lesson

  • Choose the right combination from all modern JavaScript flags (g, i, m, s, u, v, y, d).
  • Use the s (dotAll) flag to also match the carriage return characters \n to the dot ..
  • Understand the basics of the v flag (unicodeSets, ES2024) for set operations such as subtraction -- and intersection &&.

Overview

flags are single-letter modifiers that change the behavior of the entire regex engine without rewriting the pattern. They can be combined in any order after the closing slash (JavaScript then orders them canonically in re.flags).

Think of flags like switches on the regex dashboard: the pattern describes what to look for, while the flags decide how the engine interprets the text (all of it or just the first match? Case sensitive? Multiline? Advanced Unicode?).

Sections covered in this lesson

  1. 1Mental model: engine configuration switches
  2. 24 progressive examples step by step
  3. 3Guided practical exercises
  4. 4Quick check
Pro Lesson · Module 7 — Flags, substitution, split

Unlock "All flags in detail" and the full Regex Course curriculum

`g i m s u v y d`: what each one does and how they combine.

Unlock all 5 hands-on exercises in this lesson plus every advanced WebAssembly module with automated checks.

  • Instant access to all advanced modules in Regex Course plus 17 more courses
  • Hands-on browser exercises with automated test suites and solutions
  • 14-day money-back guarantee processed via Paddle.com

14-day guarantee · Cancel anytimeModule 1, all 18 interactive games, and cheatsheets are always free.