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