Babel plugin that transforms ES2015 sticky regex literals to ES5-compatible RegExp constructor calls
Overall
score
100%
A small transformer that rewrites sticky regex literals in JavaScript source code into equivalent constructor calls while leaving other expressions untouched.
/foo/y is emitted as new RegExp("foo", "y") in the transformed output. @test/ab+c/gy is emitted as new RegExp("ab+c", "gy"), keeping both flags intact. @test/bar/g stays as the same regex literal in the output. @testnew RegExp("foo", "y") remains unchanged after transformation. @test@generates
/**
* Transforms JavaScript source code by applying a Babel plugin that rewrites sticky regex literals.
*
* @param {string} source - JavaScript source to transform.
* @returns {string} transformed source with sticky regex literals rewritten.
*/
export function transformSource(source);Babel plugin that converts sticky regex literals to RegExp constructor calls.
Install with Tessl CLI
npx tessl i tessl/npm-babel-plugin-transform-es2015-sticky-regex