A light-weight representation of JS RegExp literal.
Only the source and flags properties have to be given. source and flags are required to be syntactically
valid.
Literals are only guaranteed to be compatible with the RegExp constructor. The source may contain line breaks or
unescaped / characters. To convert a literal to a valid RegExp literal, use:
RegExp(literal.source, literal.flags).toString()
Note: A bug in v8's RegExp.properties.toString
implementation caused some line breaks to not be escaped in older versions of NodeJS. You can use
this workaround
to correct invalid RegExp literals.
A light-weight representation of JS RegExp literal.
Only the
source
andflags
properties have to be given.source
andflags
are required to be syntactically valid.Literals are only guaranteed to be compatible with the
RegExp
constructor. Thesource
may contain line breaks or unescaped/
characters. To convert a literal to a valid RegExp literal, use:Note: A bug in v8's
RegExp.properties.toString
implementation caused some line breaks to not be escaped in older versions of NodeJS. You can use this workaround to correct invalid RegExp literals.