Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // (#<identifier> rule)
- function captureNames(re) {
- var names = [];
- var ret = new RegExp( re.source.replace( /#<(\w{1,32})> /g, function(q, e) {
- names.push(e);
- return '';
- } ), (re.global ? 'g' : '') + (re.ignoreCase ? 'i' : '') + (re.multiline ? 'm' : '') );
- ret.names = names;
- function assign(m) {
- if (m == null) {
- return m;
- }
- var i = ret.names.length, j, o = {};
- while (i) {
- j = i;
- o[ ret.names[--i] ] = m[j];
- }
- return o;
- }
- ret.exec = function(str) {
- return assign( RegExp.prototype.exec.call(this, str) );
- }
- return ret;
- }
Advertisement
Add Comment
Please, Sign In to add comment