In JavaScript, regex.dotAll is a read-only boolean. It is true when the RegExp was created with the s flag.
By default, the . wildcard matches any character except a newline. With s (dotAll), . also matches newlines, so one pattern can span multiple lines.
Syntax
Create the regex with s, then read .dotAll.
JavaScript
const a = /a.b/;
const b = /a.b/s;
const c = new RegExp("a.b", "s");
console.log(a.dotAll); // false
console.log(b.dotAll); // true
console.log(c.dotAll); // true
Call
What it does
/a.b/
Dot does not match newlines. dotAll is false.
/a.b/s
Dot can match newlines. dotAll is true.
new RegExp("a.b", "s")
Same as the literal with s.
Remember this at a glance:
Remember
/a.b/.dotAll → false
/a.b/s.dotAll → true
without s: . skips \n
with s: . matches \n too
flags are fixed at creation — cannot set .dotAll = true
What You Get
Name
Description
regex.dotAll
Read-only. true if the s flag was set when the RegExp was created.
s flag
Set at creation with /…/s or new RegExp(pattern, "s").
. wildcard
With s, matches any character including newline.
Return Value
Value
Description
true
The RegExp has the s (dotAll) flag.
false
The RegExp does not have the s flag.
JavaScript Examples
Example 1 — Read dotAll
See how the s flag sets the property.
JavaScript
const a = /a.b/;
const b = /a.b/s;
const c = new RegExp("a.b", "s");
console.log(a.dotAll);
console.log(b.dotAll);
console.log(c.dotAll);
console.log(c.flags);