liveBook · Manning

Regular expression flag

Also called regex flag

A regular-expression flag is a setting that modifies how a regular expression is interpreted or matched.

How 2 Manning books explain it

The Well-Grounded Rubyist, Fourth Edition

A regexp modifier is a letter appended to a Ruby regular-expression literal that changes how matching or parsing behaves.

How it is used
Fine-tunes Ruby regexp matching for case, newline, and pattern-whitespace behavior.
How deep it goes
Defines modifier placement and explains i, m, and x through runnable contrasts, warnings, and multiline examples.
Examples
Uses /abc/i, a multiline parenthesis pattern, an expanded phone-number regexp, and %r(abc)i.
What you can do after
Apply it via Ruby regexp literals to control case sensitivity, newline matching, and readable pattern layout.

Read how The Well-Grounded Rubyist, Fourth Edition explains regular expression flag →

Secrets of the JavaScript Ninja, Third Edition

A modifier that changes the matching behavior or returned information of a regular expression.

How it is used
Modify regular-expression matching or result information, including case sensitivity, match scope, line anchors, dot behavior, and Unicode handling.
How deep it goes
Define eight flags by effect and show literal and constructor syntax, while deferring detailed regex terms and operators.
Examples
Illustrate flags with /test/ig and new RegExp("test", "ig"), plus case-insensitive and global matching behavior.
What you can do after
Configure regex literals or RegExp instances to control case sensitivity, global matching, line anchors, dotAll, Unicode, and sticky behavior.

Read how Secrets of the JavaScript Ninja, Third Edition explains regular expression flag →

Also covered in

What to know first

Related concepts

Questions about regular expression flag

What is regular expression flag?

A regular-expression flag is a setting that modifies how a regular expression is interpreted or matched.

Which Manning books explain regular expression flag?

The Well-Grounded Rubyist, Fourth Edition and Secrets of the JavaScript Ninja, Third Edition.

What should I know before learning regular expression flag?

Manning books that teach regular expression flag usually introduce operator and regular expression first.

What kinds of regular expression flag are there?

Kinds of regular expression flag include i modifier, m modifier and x modifier.

What is regular expression flag part of?

Regular expression flag is part of format string. A format string is a character sequence containing literal text and directives or placeholders that govern how supplied values are represented in formatted text.

What is regular expression flag also called?

Regular expression flag is also called regex flag.

These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.