A source code transpiler that rewrites ES2015 Unicode regular expressions with the 'u' flag into ES5-compatible equivalents.
regexpu is a source code transpiler that enables the use of ES2015 Unicode regular expressions in ES5 environments. It rewrites regular expression literals that use the `u` flag into equivalent ES5-compatible patterns, allowing developers to leverage modern Unicode regex features while maintaining compatibility with older JavaScript engines.
JavaScript developers working on projects that need to support ES5 environments but want to use ES2015 Unicode regex features like the `u` flag, Unicode property escapes, or the `s` (dotAll) flag. It is also used by transpiler maintainers integrating Unicode regex support into tools like Babel, Traceur, esnext, and Bublé.
Developers choose regexpu because it provides accurate and efficient transpilation of Unicode regular expressions, is battle-tested as the internal engine for major transpilers, and offers optional experimental support for newer regex features like the `s` flag and Unicode property escapes.
A source code transpiler that enables the use of ES2015 Unicode regular expressions in ES5.
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Accurately rewrites ES2015 regex literals with the 'u' flag into ES5-compatible patterns, enabling features like Unicode code point matching in older environments, as demonstrated in the README examples.
Used internally by major transpilers like Babel and Traceur, ensuring battle-tested reliability and seamless adoption in existing build pipelines, per the project's documentation.
Offers multiple methods including rewritePattern for individual patterns and transpileCode for entire source files, catering to different use cases like AST manipulation or direct code rewriting.
Provides optional flags for newer regex features like the 's' (dotAll) flag and Unicode property escapes, allowing early adoption in ES5 contexts with configurable options.
Cannot transpile dynamic regex patterns created with RegExp('...', 'u'), restricting its applicability to only regex literals in source code, as admitted in the known limitations.
Has known issues such as incomplete support for back-references with both 'i' and 'u' flags, and inability to accurately match lone low surrogates due to JavaScript regex constraints.
Relies on several internal dependencies like Recast and Esprima, which may bloat builds if only core functionality is needed, though modular imports are possible to mitigate this.