wild
v1.2.0
Published
Generate regexp by wildcard string
Downloads
15
Readme
wild
[![NPM version][npm-image]][npm-url] [![Downloads][downloads-image]][downloads-url] [![Dependency Status][david-image]][david-url] [npm-image]: https://img.shields.io/npm/v/wild.svg?style=flat-square [npm-url]: https://npmjs.org/package/wild [downloads-image]: http://img.shields.io/npm/dm/wild.svg?style=flat-square [downloads-url]: https://npmjs.org/package/wild [david-image]: http://img.shields.io/david/chunpu/wild.svg?style=flat-square [david-url]: https://david-dm.org/chunpu/wild
Generate regexp by wildcard string
Installation
npm i wild
Api
wild(str[, isStrict])
=> return regexp
if isStrict is true, wild will return regexp like /^ ... $/
Usage
wild only cares about the wildcard *
, and escape other special chars in regexp
var wild = require('wild')
var reg = wild('http://google.com/*', true)
// => /^http:\/\/google\.com\/.*$/
reg.test('http://google.com/foo')
// => true
Advanced
get source by wild.source
wild.source('http://google.com/*')
// => 'http://google\\.com/.*'
// different with raw source
wild('http://google.com/*').source
// => 'http:\/\/google\.com\/.*'