Extras
match
match
Include another readable RegExp token in the current expression. This is useful for extracting and re-using common expressions.
Example:
This is equivalent to:
match
can also accept multiple tokens and chain them together, which can be useful for code formatting.
Example:
This is equivalent to:
toString()
toString()
Get the current expression as a RegExp string. This is a terminal operation, which means no more functions can be chained after toString
, and the string output cannot be converted back to a readable RegExp token.
Back-references are validated when toString
is called, and an error will be thrown if any of the back-references are invalid.
Example:
toRegExp(flags?)
toRegExp(flags?)
Get a RegExp object of the current expression. This is a terminal operation, which means no more functions can be chained after toRegExp
, and the output cannot be converted back to a readable RegExp token.
Back-references are validated when toRegExp
is called, and an error will be thrown if any of the back-references are invalid.
You can supply a list of flags to set in the RegExp object:
toRegExp('gmi')
toRegExp`gmi`
toRegExp(Flag.Global, Flag.MultiLine, Flag.IgnoreCase)
toRegExp('g', 'm', 'i')
Last updated