2.0.0 • Published 8 years ago

ifade v2.0.0

Weekly downloads
2
License
MIT
Repository
github
Last release
8 years ago

ifade

Extended Regular Expression (RegExp) for named matches.

Installation

$ npm install ifade --save

Usage

const Ifade = require('ifade');

Named Regular Expressions

let pattern = '/user/:userId';
Ifade.shouldConvert(pattern); // true

let ifade = new Ifade(pattern);
ifade.match('/user/1234'); // {'userId': '1234'}

Other Special Characters

(new Ifade('ab*c')).match('abc'); // {match: 'abc'}
(new Ifade('ab*c')).match('abxc'); // {match: 'abxc'}

(new Ifade('ab+c')).match('abc'); // {match: 'abc'}
(new Ifade('ab+c')).match('abbbc'); // {match: 'abbbc'}

(new Ifade('ab?c')).match('abc'); // {match: 'abc'}
(new Ifade('ab?c')).match('ac'); // {match: 'ac'}

(new Ifade('a(bc)?d')).match('ad'); // {match: 'ad'}
(new Ifade('a(bc)?d')).match('abcd'); // {match: 'abcd'}

(new Ifade('a(b|c)d')).match('abd'); // {match: 'abd'}
(new Ifade('a(b|c)d')).match('acd'); // {match: 'acd'}
More...