A small isomorphic library that lets you name regex capture groups.
Named capturing lets you name the captures you do in your regex matches. So instead of having to get the captured strings from a regex match out of an array using their index you can get them using their name.
This is a feature that is implemented natively in a lot of other languages like Ruby, PHP and Perl but not in JavaScript yet, thats why this library is here.
With Native JS
let m = 'user 271 tel 789-218-212'.match(/user (\d+) tel ([0-9\-]+)/);
if(m && m[1] && m[2])With NamedRegex
let m = new NamedRegex(/user (:<id>\d+) tel (:<tel>[0-9\-]+)/);
if(m.id && m.tel)npm install namedregex --save- Import and use
import NamedRegex from 'namedregex';
let namedRegex = new NamedRegex(/user (:<id>\d+)/);
namedRegex.match('user 218'); //{ id: 218 }