Last active
July 21, 2019 07:38
-
-
Save luisenriquecorona/5f80173e988c86d2b2a12ced8930bdb3 to your computer and use it in GitHub Desktop.
ES6
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 getFlags(re) { | |
var text = re.toString(); | |
return text.substring(text.lastIndexOf("/") + 1, text.length); | |
} | |
// toString() is "/ab/g" | |
var re = /ab/g; | |
console.log(getFlags(re)); // "g" | |
let re = /ab/g; | |
console.log(re.source); // "ab" | |
console.log(re.flags); // "g" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment