regex - how to replace more than one matched string in Emacs Regexp? -
in emacs regexp, i'm doing replace-regexp, searching this
<span class="small">\([^<]+\)</span>\([^<]+\)<span class="small">\([^<]+\)</span>
and trying replace this
<span class="small">\1\2</span>
i'm trying concatenate 2 matched strings. doing wrong?
without description of how doesn't work you, can guess intended replace \1\3
rather \1\2
.
a second possibility text operating on doesn't match regex.
(switch-to-buffer (get-buffer-create "nst.html")) (insert "<span class=\"small\">foo</span>bar<span class=\"small\">baz</span>") (goto-char (point-min)) (replace-regexp "<span class=\"small\">\\([^<]+\\)</span>\\([^<]+\\)<span class=\"small\">\\([^<]+\\)</span>" "<span class=\"small\">\\1\\3</span>")
try m-x undo
in buffer see looked before replacement operation.
(i suppose losing text in \2
intention?)