* regexp-quote for replacements
@ 2004-09-12 18:13 Roland Winkler
2004-09-13 16:17 ` Stefan Monnier
0 siblings, 1 reply; 2+ messages in thread
From: Roland Winkler @ 2004-09-12 18:13 UTC (permalink / raw)
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
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: regexp-quote for replacements
2004-09-12 18:13 regexp-quote for replacements Roland Winkler
@ 2004-09-13 16:17 ` Stefan Monnier
0 siblings, 0 replies; 2+ messages in thread
From: Stefan Monnier @ 2004-09-13 16:17 UTC (permalink / raw)
> 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.
> ;; the following is like regexp-quote for replacements?
> (baz (replace-regexp-in-string "\\\\" "\\\\" bar nil t)))
Yes, this will do a "quote" w.r.t the `literal' argument of
replace-match. But it won't protect from case-fiddling. For that I think
the only solution is the `fixedcase' argument (i.e. global to the
whole replacement text).
Stefan
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2004-09-13 16:17 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-09-12 18:13 regexp-quote for replacements Roland Winkler
2004-09-13 16:17 ` Stefan Monnier
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.