aboutsummaryrefslogtreecommitdiff
path: root/files/zh-cn/web/javascript/reference/global_objects/regexp/dotall/index.html
blob: 8608cfd1c20b33c81fe6f86792561df42403246c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
---
title: RegExp.prototype.dotAll
slug: Web/JavaScript/Reference/Global_Objects/RegExp/dotAll
tags:
  - JavaScript
  - 修饰符
  - 正则表达式
translation_of: Web/JavaScript/Reference/Global_Objects/RegExp/dotAll
---
<p>{{JSRef}}{{Draft}}</p>

<p><strong><code>dotAll</code></strong> 属性表明是否在正则表达式中一起使用"<code>s</code>"修饰符(引入/s修饰符,使得.可以匹配任意单个字符)。<code>dotAll</code> 是一个只读的属性,属于单个正则表达式实例。</p>

<p>{{JS_Property_Attributes(0, 0, 1)}}</p>

<h2 id="描述">描述</h2>

<p>如果使用了"<code>s</code>"修饰符,<code>dotAll</code> 的值将返回{{JSxRef("Boolean")}}类型的<code>true</code>,否则将返回<code>false</code>。"<code>s</code>"修饰符表示,特殊字符"<code>.</code>"应另外匹配字符串中的下述行终结符(line terminator characters),否则将会失配:</p>

<ul>
 <li>U+000A 换行符("<code>\n</code>")</li>
 <li>U+000D 回车符("<code>\r</code>")</li>
 <li>U+2028 行分隔符(<span class="message-body-wrapper"><span class="message-flex-body"><span class="devtools-monospace message-body"><span class="objectBox objectBox-string">line separator</span></span></span></span></li>
 <li>U+2029 段分隔符(<span class="message-body-wrapper"><span class="message-flex-body"><span class="devtools-monospace message-body"><span class="objectBox objectBox-string">paragraph separator</span></span></span></span></li>
</ul>

<p>这实际上意味着"<code>.</code>"将会匹配任意的单个Unicode Basic Multilingual Plane (BMP)字符。若要使其与astral字符(大于\uFFFF的Unicode字符)匹配,你应当使用"<code>u</code>"(Unicode)修饰符。一起使用这两个修饰符,"<code>.</code>"将无一例外地匹配任意Unicode字符。</p>

<p>无法直接修改此属性。</p>

<h2 id="浏览器兼容性">浏览器兼容性</h2>

<div class="hidden">The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out <a href="https://github.com/mdn/browser-compat-data">https://github.com/mdn/browser-compat-data</a> and send us a pull request.</div>

<p>{{Compat("javascript.builtins.RegExp.dotAll")}}</p>

<h2 id="相关链接">相关链接</h2>

<ul>
 <li>{{JSxRef("RegExp.lastIndex")}}</li>
 <li>{{JSxRef("RegExp.prototype.global")}}</li>
 <li>{{JSxRef("RegExp.prototype.ignoreCase")}}</li>
 <li>{{JSxRef("RegExp.prototype.multiline")}}</li>
 <li>{{JSxRef("RegExp.prototype.source")}}</li>
 <li>{{JSxRef("RegExp.prototype.sticky")}}</li>
 <li>{{JSxRef("RegExp.prototype.unicode")}}</li>
</ul>