我有一个字符串向量,而且这些字符串基本上都是一个文本文档,格式类似于markdown。
文档中有些部分看起来像这样:
===FooHeader===
stuff...
more stuff...
----
该部分的末尾用4个破折号表示。
所以在我所拥有的这个载体中,可能有很多部分。
我想从文档中提取一个特定部分。
这样做的惯用方法是什么?
答案 0 :(得分:4)
它看起来像这样:
(defn find-region [start? end? data]
(take-while (complement end?)
(drop-while (complement start?) data)))
user=> (find-region #{1} #{-1} [10 20 30 1 30 4 2 3 4 -1 1])
;;=> (1 30 4 2 3 4)
或在你的情况下:
(find-region #{"===FooHeader==="} #{"----"} lines)