Provides

A few super-handy tools for messing around with RegExp

License:
MIT
Authors:
Thomas Aylott
  1. 14
  2. 15
  3. 16
  4. 17
  5. 18
  6. 19
  7. 20
  8. 21
  9. 22
  10. 23
  11. 24
  12. 25
  13. 26
  14. 27
  15. 28
  16. 29
  17. 30
  18. 31
  19. 32
  20. 33
  21. 34
  22. 35
;(function(exports){ exports.combineRegExp = function(regex, group){ if (regex.source) regex = [regex] var names = [], i, source = '', this_source for (i = 0; i < regex.length; ++i){ if (!regex[i]) continue this_source = regex[i].source || ''+regex[i] if (this_source == '|') source += '|' else { source += (group?'(':'') + this_source.replace(/\s/g,'') + (group?')':'') if (group) names.push(group) } if (regex[i].names) names = names.concat(regex[i].names) } try { regex = new RegExp(source,'gm') } catch (e){ throw new SyntaxError('Invalid Syntax: ' + source +'; '+ e) }

[key] → 1

  1. 37
for (i = -1; i < names.length; ++i) names[names[i]] = i + 1

[1] → key

  1. 39
  2. 40
  3. 41
  4. 42
  5. 43
regex.names = names return regex } }(typeof exports != 'undefined' ? exports : this))