code: function matches(regex, str) {
      var ret = [];
      var match = regex.exec(str);
      while (match !== null) {
          ret.push({
              full: match[0],
              inner: match[1]
          });
          match = regex.exec(str);
      }
      return ret;
  }
docs: https://stackoverflow.com/a/432503