Created
July 28, 2020 08:43
-
-
Save mholtzhausen/af6d9f974e6ff8cf44e101b2a7d082dd to your computer and use it in GitHub Desktop.
Regex Named Matches Wrapper
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
function regexMatch(regex, str){ | |
let m; | |
let g=[] | |
while ((m = regex.exec(str)) !== null) { | |
if (m.index === regex.lastIndex) { | |
regex.lastIndex++; | |
} | |
g.push({...m.groups}) | |
} | |
return g | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment