SuperReg
Better RegExp support for Javascript
Usage
SuperReg extends from RegExp
. It adds a few extra methods.
const reg = /^[a-z]/const matches = reg// matches === [ 'a123', '123' ]
Methods
static escape (str pattern) str
Escapes all special chars in a string to make it usable as a RegExp.
const pat = SuperReg// pat === Hello \$\{name\}
map (arr pattern) obj
Maps an array of keys onto a regexp
const keys = 'one' 'two' 'three' const pattern = /||/const res = pattern// res = { one: '', two: '', 'three: 'three' }