Clojureからのxml・正規表現
camprojファイルから吹き出しのテキストを抽出するClojureのプログラムを書いた。
CamtasiaHukidashi/hukidashi.clj at master · Mozk0/CamtasiaHukidashi · GitHub
- clojure.xml, clojure.zip, clojure.contrib.zip-filter, clojure.contrib.zip-filter.xml を使うとxmlをスイスイと操作できる。
- clojure.contrib.str-utils の re-partition を基にして関数を書けば大抵のことはどうにかなる。
(apply str (re-map #(* 2 (Integer. %)) #"\d+" "aaa123aaa50a")) ;=> "aaa246aaa100a"
これとか結構便利?