babel/packages/babel-plugin-transform-unicode-property-regex
Mathias Bynens 5d4c736413 Import babel-plugin-transform-unicode-property-regex (#6499)
* Import babel-plugin-transform-unicode-property-regex

Original: https://github.com/mathiasbynens/babel-plugin-transform-unicode-property-regex

Moving it into the official Babel repository makes it easier to maintain the transform.

* Update package.json

* Update README.md

* fixup

* fixup 2
2017-10-18 13:58:44 -04:00
..

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

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

Note: the Unicode property escape syntax is non-standard and may or may not reflect what eventually gets specified.

Heres an online demo.

Installation

$ npm install @babel/plugin-transform-unicode-property-regex

Usage

.babelrc

{
  "plugins": ["transform-unicode-property-regex"]
}

Via CLI

$ babel --plugins transform-unicode-property-regex script.js

Via Node.js API

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

To transpile to ES6/ES2015:

require('@babel/core').transform(code, {
  'plugins': [
    ['transform-unicode-property-regex', { 'useUnicodeFlag': true }]
  ]
});

Author

twitter/mathias
Mathias Bynens