JSPM

  • Created
  • Published
  • Downloads 34697957
  • Score
    100M100P100Q272421F
  • License MIT

Compile ES2015 Unicode regex to ES5

Package Exports

  • @babel/plugin-transform-unicode-regex

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@babel/plugin-transform-unicode-regex) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

@babel/plugin-transform-unicode-regex

Compile ES2015 unicode regex to ES5

Example

In

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

Out

var string = "foo💩bar";
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

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

Usage

.babelrc

{
  "plugins": ["@babel/plugin-transform-unicode-regex"]
}

Via CLI

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

Via Node API

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