Single-line and Multiline

In the Modifiers flyout are two sets of modifiers, Single-line On/Off and Multiline On/Off. These modifiers influence the behavior of the . wildcard (“match everything”) and the location markers ^ (beginning of paragraph) and $ (paragraph end).

Single-line mode determines the behavior of . (the dot wildcard). When single-line mode is off, which is GREP’s default state, .* matches everything from the cursor position to the end of the paragraph, except the paragraph mark itself. Enable single-line mode (with (?s)), and .* ignores paragraph marks, selecting everything from the insertion point to the end of the story. If there is no insertion point and you have a text frame selected, (?s).* selects the whole story—not just the text in the selected text frame—including any overset text.

The single-line/multiline settings influence the behavior of ^ and $. When multiline is enabled, which is the default state, ^ and $ match the beginning and the end of each paragraph, respectively; they respect paragraph boundaries. If multiline is disabled with (?-m), ^ and $ ignore the paragraph boundaries and become in effect beginning-of-story and end-of-story markers—synonymous with \A and \z.

Get GREP in InDesign now with the O’Reilly learning platform.

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.