babel/packages/babel-plugin-proposal-unicode-property-regex
Mathias Bynens 96c0415c86
Remove outdated sentence from README (#7311)
Unicode property escapes are now part of ECMAScript proper.

[skip ci]
2018-02-01 14:27:13 -08:00
..
2018-01-30 15:27:19 -05:00

@babel/plugin-proposal-unicode-property-regex

Compile Unicode property escapes (\p{…} and \P{…}) in Unicode regular expressions to ES5 or ES6 that works in todays environments.

Heres an online demo.

Installation

npm install --save-dev @babel/plugin-proposal-unicode-property-regex

Usage

.babelrc

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

Via CLI

babel --plugins @babel/@babel/plugin-proposal-unicode-property-regex script.js

Via Node.js API

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

To transpile to ES6/ES2015:

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

Options

  • useUnicodeFlag (defaults to true)

When disabled with false, the transform converts Unicode regexes to non-Unicode regexes for wider support, removing the u flag. See https://github.com/mathiasbynens/regexpu-core#useunicodeflag-default-false for more information.

Author

twitter/mathias
Mathias Bynens