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ì ê°ë³ ì ê·ì ì¸ì¤í´ì¤ì ì½ê¸° ì ì© ìì±ì
ëë¤.
ìëí´ ë³´ê¸°
const regex1 = new RegExp("foo", "s");
console.log(regex1.dotAll);
// Expected output: true
const 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 ì¬ì©í기
const str1 = "bar\nexample foo example";
const regex1 = /bar.example/s;
console.log(regex1.dotAll); // true
console.log(str1.replace(regex1, "")); // foo example
const str2 = "bar\nexample foo example";
const regex2 = /bar.example/;
console.log(regex2.dotAll); // false
console.log(str2.replace(regex2, ""));
// bar
// example foo example
ëª ì¸ì
| Specification |
|---|
| ECMAScript® 2027 Language Specification> # sec-get-regexp.prototype.dotAll> |