RegExp.prototype.dotAll

草案
本页尚未完工.

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

RegExp.prototype.dotAll 属性的属性特性:
writable false
enumerable false
configurable true

描述

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

  • U+000A 换行符("\n")
  • U+000D 回车符("\r")
  • U+2028 行分隔符(line separator
  • U+2029 段分隔符(paragraph separator

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

无法直接修改此属性。

浏览器兼容性

Update compatibility data on GitHub
DesktopMobileServer
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidFirefox for AndroidOpera for AndroidSafari on iOSSamsung InternetNode.js
dotAllChrome Full support 62Edge No support NoFirefox No support NoIE No support NoOpera Full support 49Safari Full support 12WebView Android Full support 62Chrome Android Full support 62Firefox Android No support NoOpera Android Full support 46Safari iOS Full support 12Samsung Internet Android Full support 8.0nodejs Full support 8.10.0
Full support 8.10.0
Full support 8.3.0
Disabled
Disabled From version 8.3.0: this feature is behind the --harmony runtime flag.

Legend

Full support  
Full support
No support  
No support
User must explicitly enable this feature.
User must explicitly enable this feature.

相关链接