|
From: | Stefan Monnier |
Subject: | Re: regexp repacement, how to present replacement to user? |
Date: | Sun, 14 Oct 2007 23:20:15 -0400 |
User-agent: | Gnus/5.11 (Gnus v5.11) Emacs/23.0.50 (gnu/linux) |
> (let ((from "\\([[:alpha:]]+\\)-\\([[:alpha:]]+\\)") > (to "\\1 \\2")) > (while (re-search-forward from nil t) > (if (y-or-n-p (format "Replace %s with %s " > (match-string 0) > (replace-regexp-in-string from to (match-string > 0)))) > (replace-match to nil nil)))) This work 99% with the last 1% being due to failure in boundary conditions (e.g. if the pattern starts with "\\>"). Stefan
[Prev in Thread] | Current Thread | [Next in Thread] |