Movatterモバイル変換


[0]ホーム

URL:


  1. Web
  2. JavaScript
  3. Reference
  4. Standard built-in objects
  5. RegExp
  6. dotAll

RegExp.prototype.dotAll

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since ⁨July 2020⁩.

ThedotAll accessor property ofRegExp instances returns whether or not thes flag is used with this regular expression.

Try it

const regex1 = /f.o/s;console.log(regex1.dotAll);// Expected output: trueconst regex2 = /bar/;console.log(regex2.dotAll);// Expected output: false

Description

RegExp.prototype.dotAll has the valuetrue if thes flag was used; otherwise,false. Thes 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:

  • U+000A LINE FEED (LF) (\n)
  • U+000D CARRIAGE RETURN (CR) (\r)
  • U+2028 LINE SEPARATOR
  • U+2029 PARAGRAPH SEPARATOR

This effectively means the dot will match any UTF-16 code unit. However, it willnot match characters that are outside of the Unicode Basic Multilingual Plane (BMP), also known as astral characters, which are represented assurrogate pairs and necessitate matching with two. patterns instead of one.

js
"😄".match(/(.)(.)/s);// Array(3) [ "😄", "\ud83d", "\ude04" ]

Theu (unicode) flag can be used to allow the dot to match astral characters as a single character.

js
"😄".match(/./su);// Array [ "😄" ]

Note that a pattern such as.* is still capable ofconsuming astral characters as part of a larger context, even without theu flag.

js
"😄".match(/.*/s);// Array [ "😄" ]

Using both thes andu flags in conjunction allows the dot to match any Unicode character in a more intuitive manner.

The set accessor ofdotAll isundefined. You cannot change this property directly.

Examples

Using dotAll

js
const str1 = "bar\nexample foo example";const regex1 = /bar.example/s;console.log(regex1.dotAll); // trueconsole.log(str1.replace(regex1, "")); // foo exampleconst str2 = "bar\nexample foo example";const regex2 = /bar.example/;console.log(regex2.dotAll); // falseconsole.log(str2.replace(regex2, ""));// bar// example foo example

Specifications

Specification
ECMAScript® 2026 Language Specification
# sec-get-regexp.prototype.dotAll

Browser compatibility

See also

Help improve MDN

Learn how to contribute

This page was last modified on byMDN contributors.


[8]ページ先頭

©2009-2025 Movatter.jp