Alternative Lib for regular expressions.
Instead of getting array get an object with keys you specify. See Usage section.
npm install --save regnumimport 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' }Simply run
npm testMore examples of usage are provided in ./test folder.
Contribution is welcome.
lodash is the only dependency to this package.
MIT © Flycode LLC
