@babel/plugin-transform-unicode-regex

Example

In

  1. var string = "foo💩bar";
  2. var match = string.match(/foo(.)bar/u);

Out

  1. var string = "foo💩bar";
  2. var match = string.match(/foo((?:[\0-\t\x0B\f\x0E-\u2027\u202A-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]))bar/);

Installation

  1. npm install --save-dev @babel/plugin-transform-unicode-regex

Usage

.babelrc

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

Via CLI

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

Via Node API

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