help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

regexp-quote for replacements


From: Roland Winkler
Subject: regexp-quote for replacements
Date: 12 Sep 2004 20:13:29 +0200
User-agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3.50

I want to construct replacement patterns automatically.
Does the following piece of code insert the value of bar in the
replacement, no matter what the string bar is?
The point is that I want the optional arg LITERAL of replace-match
to be nil.

(let* ((foo "foo")
       ;; this string should appear in the replacement
       (bar "bar.\\")
       ;; the following is like regexp-quote for replacements?
       (baz (replace-regexp-in-string "\\\\" "\\\\" bar nil t)))
  (string-match "\\(foo\\)" foo)
  (replace-match (concat "\\1 " baz " \\1") nil nil foo))


Thanks a lot,

Roland

reply via email to

[Prev in Thread] Current Thread [Next in Thread]