Last active
December 20, 2015 01:49
-
-
Save Bacra/6052174 to your computer and use it in GitHub Desktop.
The string into a regular expression By RegExp Class
This file contains 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
/** | |
* The string into a regular expression By RegExp Class | |
* | |
* @author Bacra Woo <Bacra.Woo@gmail.com> | |
*/ | |
var toRegExp = function(str){ | |
var mark; | |
return new RegExp(str.substring(1).replace(/\/([igm]*)$/, function(match, modifiers){ | |
mark = modifiers; | |
return ''; | |
}), mark); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment