UNPKG

854 BMarkdownView Raw
1# babel-plugin-transform-es2015-unicode-regex
2
3> Compile ES2015 unicode regex to ES5
4
5## Example
6
7**In**
8
9```js
10var string = "foo💩bar";
11var match = string.match(/foo(.)bar/u);
12```
13
14**Out**
15
16```js
17var string = "foo💩bar";
18var 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/);
19```
20
21## Installation
22
23```sh
24npm install --save-dev babel-plugin-transform-es2015-unicode-regex
25```
26
27## Usage
28
29### Via `.babelrc` (Recommended)
30
31**.babelrc**
32
33```json
34{
35 "plugins": ["transform-es2015-unicode-regex"]
36}
37```
38
39### Via CLI
40
41```sh
42babel --plugins transform-es2015-unicode-regex script.js
43```
44
45### Via Node API
46
47```javascript
48require("babel-core").transform("code", {
49 plugins: ["transform-es2015-unicode-regex"]
50});
51```