Package Exports
- regexr
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (regexr) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
regexr
For composing regular expressions.
Regexr provides an ES6 template tag function that makes it easy to compose regexes out of template strings without double-escaped hell.
For example, in ES5 and below, you would have to do something like the following to compose a regular expression.
var spaceRegex = '\\s*'
var finalRegex = '\\('+spaceRegex+'\\/\\[\\\\\\d+\\]\\)*$'
finalRegex = new RegExp(finalRegex, 'g')
console.log( !!'( /[\\12358])'.match(finalRegex) ) // true
Imagine making more complex regexes. Good luck with that!
Well, with regexr, now you can do what you always wanted to do:
Usage
var r = require('regexr')
var spaceRegex = r`\s*`
var finalRegex = r`/\(${spaceRegex}\/\[\\\d+\]\)*$/g`
console.log( !!'( /[\\12358])'.match(finalRegex) ) // true
You can also use pre-seleted, hand-picked regexes to compose with:
var r = require('regexr')
var functionCallRgx = r`${r.identifier}\s*\(\s*${r.identifier}\s*\)`
console.log(!!"foo ( bar )".match(functionCallRgx)) // true
Hand-picked Regexes
r.identifier
Matches a valid JavaScript identifier. See this for details.