@babel/plugin-proposal-unicode-property-regex
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.
Installation
npm install @babel/plugin-proposal-unicode-property-regex
Usage
Via .babelrc (recommended)
.babelrc
{
"plugins": ["@babel/proposal-unicode-property-regex"]
}
Via CLI
babel --plugins @babel/@babel/proposal-unicode-property-regex script.js
Via Node.js API
require("@babel/core").transform(code, {
"plugins": ["@babel/proposal-unicode-property-regex"]
});
To transpile to ES6/ES2015:
require("@babel/core").transform(code, {
"plugins": [
["@babel/proposal-unicode-property-regex", { "useUnicodeFlag": false }]
]
});
Options
useUnicodeFlag(defaults totrue)
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
| Mathias Bynens |