memo:matchした文字列の内容を返すre-search-forward

(defun match-data-to-string-list (data)
  (let (begs ends)
    (while data
      (push (pop data) begs)
      (push (pop data) ends))
    (loop for beg in begs
          for end in ends
          for i from 0 to (length begs)
          if (and beg end)
          collect (list i (buffer-substring-no-properties beg end))
          else
          collect (list i))))

(defun re-search-forward/return-matched-string (rx &optional bound noerror count)
  (and (re-search-forward rx bound noerror count)
       (match-data-to-string-list (match-data))))