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 UTF-16 code unit. However, it will not match characters that are outside of the Unicode Basic Multilingual Plane (BMP), also known as astral characters, which are represented as surrogate pairs and necessitate matching with two .
patterns instead of one.
"ð".match(/(.)(.)/s);
// Array(3) [ "ð", "\ud83d", "\ude04" ]
The u
(unicode) flag can be used to allow the dot to match astral characters as a single character.
"ð".match(/./su);
// Array [ "ð" ]
Note that a pattern such as .*
is still capable of consuming astral characters as part of a larger context, even without the u
flag.
"ð".match(/.*/s);
// Array [ "ð" ]
Using both the s
and u
flags in conjunction allows the dot to match any Unicode character in a more intuitive manner.
The set accessor of dotAll
is undefined
. You cannot change this property directly.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4