1.0.0 • Published 7 years ago

regnum v1.0.0

Weekly downloads
5
License
MIT
Repository
github
Last release
7 years ago

Regnum

Regnum Logo

Instead of getting array get an object with keys you specify. See Usage section.

Install

npm install --save regnum

Usage

import Regnum from "regnum"

regnumObject = {
    username: '[a-zA-Z0-9.!#$%&’*+/=?^_`{|}~-]+',
    domain: '[a-zA-Z0-9-]+',
    zone: '(?:\.[a-zA-Z0-9-]+)*'
};

regnum = new Regnum('^($username$)@($domain$)($zone$)$', regnumObject);
matchedObject = regnum.match('bender@ilovebender.com');

Result of matchedObject is

{
    username: 'bender',
    domain: 'ilovebender',
    zone: '.com'
}

Test

Simply run

npm test

Examples

More examples of usage are provided in ./test folder.

Contribution

Contribution is welcome.

Dependencies

lodash is the only dependency to this package.

License

MIT © Flycode LLC