Compile Unicode property escapes (\p{…}
and \P{…}
) in Unicode regular expressions to ES5 or ES6 that works in today’s environments.
Note: the Unicode property escape syntax is non-standard and may or may not reflect what eventually gets specified.
$ npm install babel-plugin-transform-unicode-property-regex
.babelrc
{
"plugins": ["transform-unicode-property-regex"]
}
$ babel --plugins transform-unicode-property-regex script.js
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 }]
]
});
Mathias Bynens |
This code is available under the MIT license.