regular expressions inside of template literals
npm install --save template-regexp
- removes need to double escape
- supports auto escaping of embeded expressions
- automatically returns a valid RegExp
- g - adds global flag
- i - adds ignore flag
- m - adds multiline flag
- u - adds unicode flag
- y - adds sticky flag
- _ - clears flags on regexp
import r from 'template-regexp';
r`foo(bar)` // => /foo(bar)/
r`foo(bar)`.g // => /foo(bar)/g
r`foo${'(bar)'}`.g // => /foo\(bar\)/g
r`foo(${'(bar)'})`.g // => /foo(\(bar\))/g
r`foo(${'(bar)'})`.g.i.m.u.y // => /foo(\(bar\))/gimuy