Skip to content

Instantly share code, notes, and snippets.

@Saneyan
Last active December 10, 2015 01:34
Show Gist options
  • Select an option

  • Save Saneyan/4358766 to your computer and use it in GitHub Desktop.

Select an option

Save Saneyan/4358766 to your computer and use it in GitHub Desktop.
Integrate regular expressions.
function integrateRegExp( regExps, flag ){
var source = '';
for( var regExp, i = 0; regExp = regExps[ i++ ]; ){
source += regExp.source;
}
return new RegExp( source, flag );
}
integrateRegExp([ /a/, /b/, /c/, /d/, /e/ ], 'g' ); // /abcde/g
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment