path-to-regex
Turn a path string such as /user/:id
or /user/:id(\d+)
into a regular expression
![Downloads](http://img.shields.io/npm/dm/path-to-regex.svg?style=flat)
Installation
npm install path-to-regex --save
Usage
var pathToRegex = require('path-to-regex');
var matcher = new pathToRegex(path_template, options?);
- path_template A string or a regular expression.
- options
- case When
true
the regexp will be case sensitive. (default: true
) - splitters The chars list for splited patch string. (default:
'/'
) - escapeChars The chars list for escaped. (default:
'/'
) - fromStart When
true
the regexp will match from the beginning of the string. (default: true
) - toEnd When
true
the regexp will match to the end of the string. (default: true
)
var pathToRegex = require('path-to-regex');
var matcher = new pathToRegex('/foo/:bar');
var result = matcher.match('/foo/12345');
... documentation in processed