(while (re-search-forward "^[\t ]*%.*\n" nil t)
(delete-region (match-beginning 0) (match-end 0))))
(setq str (buffer-string)))
(while (re-search-forward "^[\t ]*%.*\n" nil t)
(delete-region (match-beginning 0) (match-end 0))))
(setq str (buffer-string)))