Forked from goofballLogic/gist:61e4e7df3e7671b9ff66114a32c8ad9d
Created
September 26, 2016 16:28
-
-
Save tenbits/ec7f0155b57b2d61a6cc90ef3d5f8b49 to your computer and use it in GitHub Desktop.
Not sure that serialization "works"
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
var x = new RegExp( "/" ) | |
console.log(x.test( "/hello" )); | |
var serializedRegexParser = /^\/(.+)\/(\w+)?$/ | |
var serializedRegex = x.toString(); | |
console.log('serializedRegex:', serializedRegex); | |
var matches = serializedRegexParser.exec(serializedRegex); | |
var [full, regexString, regexFlags] = matches; | |
console.log('regexString:', regexString); | |
var y = new RegExp(regexString, regexFlags); | |
console.log(y.test( "/hello" )); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment