Emacs XML模式:文本中的搜索和替换(不是标记)

时间:2012-03-18 11:00:11

标签: xml emacs replace

在Emacs中是否有一种简单的方法来搜索和替换XML文件中的文本,但是对于s& r操作来说只对文档文本起作用,而不是标记?

例如:

...
There is some text above here
[mark-starts-here]
<some_tag key="value">
  text
</some_tag>
[mark-ends-here]
There is some text below here
...

e替换为E以获取:

...
There is some text above here
[mark-starts-here]
<some_tag key="value">
  tExt
</some_tag>
[mark-ends-here]
There is some text below here
...

1 个答案:

答案 0 :(得分:1)

我不知道xml模式是否具有类似内置的功能,但这是一个简单的功能:

(defun my-replace-outside-of-tags (regexp replacement)
  (while (re-search-forward regexp nil t)
    (unless (save-match-data
              (looking-at "[^<>]*>"))
      (replace-match replacement))))