Flags.js

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"
ES6

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.