我想去掉以下string里尖括号中的所有内容,包含尖括号本身。
(defvar temp-string "<a href=\"/locus/S000004071\">GAL2</a> encodes a high affinity <a href=\"/go/5354\">galactose permease</a> that is also able to <a href=\"/go/5355\">transport glucose</a> (<span data-tooltip aria-haspopup=\"true\" class=\"has-tip\" title=\"Tschopp JF, et al. (1986)\"><a href=\"/reference/S000054945\">6</a></span>, <span data-tooltip aria-haspopup=\"true\" class=\"has-tip\" title=\"Maier A, et al. (2002)\"><a href=\"/reference/S000073003\">4</a></span>).")
(with-temp-buffer
(insert temp-string)
(goto-char (point-min))
(replace-regexp "<*>" "\&")
(buffer-string))
返回的结果是:
<a href="/locus/S000004071"&GAL2</a& encodes a high affinity <a href="/go/5354"&galactose permease</a& that is also able to <a href="/go/5355"&transport glucose</a& (<span data-tooltip aria-haspopup="true" class="has-tip" title="Tschopp JF, et al. (1986)"&<a href="/reference/S000054945"&6</a&</span&, <span data-tooltip aria-haspopup="true" class="has-tip" title="Maier A, et al. (2002)"&<a href="/reference/S000073003"&4</a&</span&).
文档里说\&
指示替代掉整个匹配上的string, 但这段代码只是把>
换成了&
。 是不是我哪里理解错了?