Last active
December 10, 2015 01:34
-
-
Save Saneyan/4358766 to your computer and use it in GitHub Desktop.
Integrate regular expressions.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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