Security News
Node.js EOL Versions CVE Dubbed the "Worst CVE of the Year" by Security Experts
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
babel-plugin-transform-es2015-unicode-regex
Advanced tools
The babel-plugin-transform-es2015-unicode-regex package is a Babel plugin that transforms ES2015 Unicode regexes into equivalent ES5 regexes. This allows developers to use Unicode regex features in environments that do not natively support them.
Transform Unicode Regex
This feature allows you to write Unicode regex patterns using the ES2015 syntax and have them transformed into equivalent ES5-compatible regex patterns. This is useful for ensuring compatibility across different JavaScript environments.
const regex = /\u{1F4A9}/u; // ES2015 Unicode regex
const transformedRegex = new RegExp('\\u{1F4A9}', 'u'); // Transformed to ES5 compatible regex
regexpu-core is a package that transforms Unicode-aware regular expressions to ES5-compatible regular expressions. It provides similar functionality to babel-plugin-transform-es2015-unicode-regex but can be used independently of Babel.
regexgen is a tool that generates regular expressions from a list of strings. While it does not specifically focus on Unicode transformations, it can be used to create optimized regex patterns that may include Unicode characters.
Compile ES2015 unicode regex to ES5
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/);
npm install --save-dev babel-plugin-transform-es2015-unicode-regex
.babelrc
(Recommended).babelrc
{
"plugins": ["transform-es2015-unicode-regex"]
}
babel --plugins transform-es2015-unicode-regex script.js
require("babel-core").transform("code", {
plugins: ["transform-es2015-unicode-regex"]
});
FAQs
Compile ES2015 Unicode regex to ES5
The npm package babel-plugin-transform-es2015-unicode-regex receives a total of 1,167,796 weekly downloads. As such, babel-plugin-transform-es2015-unicode-regex popularity was classified as popular.
We found that babel-plugin-transform-es2015-unicode-regex demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 6 open source maintainers collaborating on the project.
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.
Security News
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
Security News
cURL and Go security teams are publicly rejecting CVSS as flawed for assessing vulnerabilities and are calling for more accurate, context-aware approaches.
Security News
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.