Skip to content

Instantly share code, notes, and snippets.

@letoh
Created August 20, 2013 13:59
Show Gist options
  • Select an option

  • Save letoh/6281840 to your computer and use it in GitHub Desktop.

Select an option

Save letoh/6281840 to your computer and use it in GitHub Desktop.
parsing test
(with-current-buffer "abc"
(with-output-to-temp-buffer "*result*"
(goto-char (point-min))
(let* ((template (concat "<!-- 一篇推文開始 -->
<section>
<a class=\"username\" href=\"https://twitter.com/%s\">%s</a>
<a class=\"date\" href=\"%s\">%s</a>
<div class=\"tweetcontent\">%s</div>
</section>
<!-- 一篇推文結束 -->
"))
(pat "- \\([^:]+\\): \\(.*\\(?:\n.*\\)*?\\)\\s-*\\*DATE\\* \\[\\([^]]+\\)\\]\\s-*\\*URL\\* \\(.*\\)"))
(while (re-search-forward pat nil :no-error)
(let ((user (match-string 1))
(tweet (match-string 2))
(date (match-string 3))
(url (match-string 4)))
(print (format template user user url date tweet)))))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment