@babel/plugin-transform-dotall-regex
信息
This plugin is included in @babel/preset-env
, in ES2018
This plugin transforms regular expression literals to support the /s
flag. It does not patch the new RegExp
constructor, since its arguments cannot be pre-transformed statically: to handle runtime behavior of functions/classes, you will need to use a polyfill instead.
Example
In
JavaScript
/./s;
Out
JavaScript
/[\0-\uFFFF]/;
In
JavaScript
/./su;
Out
JavaScript
/[\0-\u{10FFFF}]/u;
Installation
- npm
- Yarn
- pnpm
npm install --save-dev @babel/plugin-transform-dotall-regex
yarn add --dev @babel/plugin-transform-dotall-regex
pnpm add --save-dev @babel/plugin-transform-dotall-regex
Usage
With a configuration file (Recommended)
.babelrc
babel.config.json
{
"plugins": ["@babel/plugin-transform-dotall-regex"]
}
Via CLI
Shell
$ babel --plugins @babel/plugin-transform-dotall-regex script.js
Via Node.js API
JavaScript
require("@babel/core").transformSync(code, {
plugins: ["@babel/plugin-transform-dotall-regex"],
});
Author
Mathias Bynens |