This page was translated from English by the community.Learn more and join the MDN Web Docs community.
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 2020년 7월.
dotAll 속성은s 플래그가 정규식과 함께 사용되는지 여부를 나타냅니다.dotAll은 개별 정규식 인스턴스의 읽기 전용 속성입니다.
In this article
시도해 보기
const regex1 = new RegExp("foo", "s");console.log(regex1.dotAll);// Expected output: trueconst regex2 = new RegExp("bar");console.log(regex2.dotAll);// Expected output: false설명
dotAll의 값은Boolean으로s 플래그가 사용된 경우true, 그렇지 않으면false입니다.s 플래그는 점 특수 문자(.)가 문자열의 다음 줄 종결자("newline") 문자와 추가로 일치해야 함을 나타냅니다.그렇지 않으면 일치하지 않습니다.
- U+000A LINE FEED (LF) (
\n) - U+000D CARRIAGE RETURN (CR) (
\r) - U+2028 LINE SEPARATOR
- U+2029 PARAGRAPH SEPARATOR
이것은 사실상 점이 유니코드 BMP(Basic Multilingual Plane)의 모든 문자와 일치한다는 것을 의미합니다. 별 기호와 일치하도록 하려면u(유니코드) 플래그를 사용해야 합니다. 두 플래그를 함께 사용하면 예외 없이 점이 모든 유니코드 문자와 일치하도록 만들 수 있습니다.
dotAll의 set 접근자는undefined, 즉 정의되지 않았습니다. 이 속성은 직접 변경할 수 없습니다.
예제
>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명세서
| Specification |
|---|
| ECMAScript® 2026 Language Specification> # sec-get-regexp.prototype.dotAll> |