@babel/plugin-transform-dotall-regex

dotall-regex - 图1info

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

  1. /./s;

Out

JavaScript

  1. /[\0-\uFFFF]/;

In

JavaScript

  1. /./su;

Out

JavaScript

  1. /[\0-\u{10FFFF}]/u;

Here’s an online demo.

Installation

  • npm
  • Yarn
  • pnpm
  1. npm install --save-dev @babel/plugin-transform-dotall-regex
  1. yarn add --dev @babel/plugin-transform-dotall-regex
  1. pnpm add --save-dev @babel/plugin-transform-dotall-regex

Usage

.babelrc

babel.config.json

  1. {
  2. "plugins": ["@babel/plugin-transform-dotall-regex"]
  3. }

Via CLI

Shell

  1. $ babel --plugins @babel/plugin-transform-dotall-regex script.js

Via Node.js API

JavaScript

  1. require("@babel/core").transformSync(code, {
  2. plugins: ["@babel/plugin-transform-dotall-regex"],
  3. });

Author

twitter/mathias
Mathias Bynens