DELAPARRA
Index
Color
NL
Category: Regex flags

/s (DotAll (single line))

Explained by Updated

What is /s (DotAll (single line))?

/s (DotAll (single line)): Makes . match newline characters too, not just non-newline characters. The s flag, often called dotall or single-line mode, makes . match newline characters too. Normally . matches any character except a line break, so a pattern like /<div>.*<\/div>/ stops at the end of the first line. With s, the same pattern can span several lines. That is what you need when extracting a block from a multi-line message, an email body or a log entry that wraps.

Definition source Coders Lingo, CC BY 4.0

Frequently asked questions about /s (DotAll (single line))

What should you keep in mind with /s (DotAll (single line))?

Combine it with care. .* with dotall is greedy and can swallow far more than you expect, all the way to the last closing tag in a large file. Use the lazy form .*? or a more specific class. For real HTML or XML, a parser is safer than any regex. Do not confuse this flag with m, which changes how ^ and $ behave.

At a glance

CategoryRegex flags
Explained by
Updated

More Regex flags terms

All terms starting with a number or symbol

Skills

Download all skills (zip)

Manuals

Related services

Need any help?

Stuck on one of these in your own project? Tell me what you are working on and I will tell you how I would approach it.