Socket
Socket
Sign inDemoInstall

@babel/plugin-transform-unicode-regex

Package Overview
Dependencies
87
Maintainers
5
Versions
68
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @babel/plugin-transform-unicode-regex

Compile ES2015 Unicode regex to ES5


Version published
Maintainers
5
Install size
1.95 MB
Created

Package description

What is @babel/plugin-transform-unicode-regex?

The @babel/plugin-transform-unicode-regex package is a plugin for Babel, a JavaScript compiler, that transforms Unicode regular expressions into equivalent ES5 syntax. This is particularly useful for ensuring compatibility with older environments that do not support Unicode property escapes in regular expressions.

What are @babel/plugin-transform-unicode-regex's main functionalities?

Transform Unicode Regular Expressions

This plugin transforms Unicode regular expressions like the one above into an ES5-compatible syntax. The 'u' flag in the regular expression indicates that it's using Unicode mode, which is not supported in older JavaScript environments. The plugin will convert this to a form that can be understood by these environments.

const regex = /\p{Script=Greek}/u;

Other packages similar to @babel/plugin-transform-unicode-regex

Readme

Source

@babel/plugin-transform-unicode-regex

Compile ES2015 unicode regex to ES5

Example

In

var string = "foo💩bar";
var match = string.match(/foo(.)bar/u);

Out

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

npm install --save-dev @babel/plugin-transform-unicode-regex

Usage

.babelrc

{
  "plugins": ["@babel/plugin-transform-unicode-regex"]
}

Via CLI

babel --plugins @babel/plugin-transform-unicode-regex script.js

Via Node API

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

Keywords

FAQs

Last updated on 17 Jan 2018

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc