diff --git a/packages/babel-plugin-transform-regexp-constructors/src/index.js b/packages/babel-plugin-transform-regexp-constructors/src/index.js index 6aa64a4bb..ddd35d653 100644 --- a/packages/babel-plugin-transform-regexp-constructors/src/index.js +++ b/packages/babel-plugin-transform-regexp-constructors/src/index.js @@ -22,6 +22,9 @@ function createRegExpLiteral(args, prettify, t) { .replace(/\f/g, "\\f") .replace(/\r/g, "\\r"); } + + pattern = pattern.replace(/\0/g, "\\0"); + return t.regExpLiteral(pattern, flags); }