Skip to content

Instantly share code, notes, and snippets.

@mholtzhausen
Created July 28, 2020 08:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mholtzhausen/af6d9f974e6ff8cf44e101b2a7d082dd to your computer and use it in GitHub Desktop.
Save mholtzhausen/af6d9f974e6ff8cf44e101b2a7d082dd to your computer and use it in GitHub Desktop.
Regex Named Matches Wrapper
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