template-regexp

0.0.2 • Public • Published

template-regexp Build Status

regular expressions inside of template literals

install

npm install --save template-regexp

regexp template strings

  • removes need to double escape
  • supports auto escaping of embeded expressions
  • automatically returns a valid RegExp

getters

  • g - adds global flag
  • i - adds ignore flag
  • m - adds multiline flag
  • u - adds unicode flag
  • y - adds sticky flag
  • _ - clears flags on regexp

usage

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

Readme

Keywords

none

Package Sidebar

Install

npm i template-regexp

Weekly Downloads

0

Version

0.0.2

License

MIT

Last publish

Collaborators

  • icodeforlove