The dotAll
accessor property indicates whether or not the s
flag is used with the regular expression.
The dotAll
accessor property indicates whether or not the s
flag is used with the regular expression.
RegExp.prototype.dotAll
has the value true
if the s
flag was used; otherwise, false
. The s
flag indicates that the dot special character (.
) should additionally match the following line terminator ("newline") characters in a string, which it would not match otherwise:
\n
)\r
)This effectively means the dot will match any character on the Unicode Basic Multilingual Plane (BMP). To allow it to match astral characters, the u
(unicode) flag should be used. Using both flags in conjunction allows the dot to match any Unicode character, without exceptions.
The set accessor of dotAll
is undefined
. You cannot change this property directly.
const str1 = 'bar\nexample foo example'; const regex1 = /bar.example/s; console.log(regex1.dotAll); // Output: true console.log(str1.replace(regex1, '')); // Output: foo example const str2 = 'bar\nexample foo example'; const regex2 = /bar.example/; console.log(regex2.dotAll); // Output: false console.log(str2.replace(regex2,'')); // Output: bar // example foo example
Desktop | Mobile | Server | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Chrome | Edge | Firefox | Internet Explorer | Opera | Safari | WebView Android | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet | Deno | Node.js | |
dotAll |
62 |
79 |
78 |
No |
49 |
11.1 |
62 |
62 |
79 |
46 |
11.3 |
8.0 |
1.0 |
8.10.0
8.3.0
|
© 2005–2022 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/dotAll