Get all matches of a regex in a string as an array
function matchAll (regex, string) {
  let match
  let matches = []
  while ((match = regex.exec(string)) !== null) {
    delete match['index']
    delete match['input']
    matches.push(match)
  }

  return matches
}