Last active
January 1, 2019 01:25
-
-
Save rauschma/cd8e51f512d374a9f3a3dfe4906c23b2 to your computer and use it in GitHub Desktop.
Revisions
-
rauschma revised this gist
Dec 31, 2018 . 1 changed file with 3 additions and 0 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -14,3 +14,6 @@ const cloneFlags = regExp.flags.includes('g') // Solution 3 const f = regExp.flags; const cloneFlags = f.includes('g') ? f : f+'g'; // Solution 4 const cloneFlags = [...new Set(regExp.flags + 'g')].join(''); -
rauschma created this gist
Dec 31, 2018 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,16 @@ // Add flag 'g' if it isn’t there, yet // Solution 1 let cloneFlags = regExp.flags; if (!cloneFlags.includes('g')) { cloneFlags += 'g'; } // Solution 2 const cloneFlags = regExp.flags.includes('g') ? regExp.flags : regExp.flags + 'g'; // Solution 3 const f = regExp.flags; const cloneFlags = f.includes('g') ? f : f+'g';