[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: regexp repacement, how to present replacement to user?
From: |
Paul Pogonyshev |
Subject: |
Re: regexp repacement, how to present replacement to user? |
Date: |
Mon, 15 Oct 2007 23:28:54 +0300 |
User-agent: |
KMail/1.7.2 |
David Kastrup wrote:
> Stefan Monnier <address@hidden> writes:
>
> >> (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 "\\>").
>
> (while (re-search-forward from nil t)
> (if y-or-n-p (format "Replace %s with %s "
> (match-string 0)
> (save-match-data
> (replace-match to nil nil (match-string 0)
> (prog1 nil
> (set-match-data
> (mapcar
> (lambda(x)(if (numberp x)
> (- x (match-beginning 0))
> x)))
> (match-data t)))
Thanks, but shouldn't this be a function somewhere? I mean, it's
not like random peope are going to easily write such code. Besides,
what if Emacs regexps are slightly improved with more features, like
named groups or whatnot?
Paul
- regexp repacement, how to present replacement to user?, Paul Pogonyshev, 2007/10/13
- Re: regexp repacement, how to present replacement to user?, Juri Linkov, 2007/10/14
- Re: regexp repacement, how to present replacement to user?, Stefan Monnier, 2007/10/14
- Re: regexp repacement, how to present replacement to user?, David Kastrup, 2007/10/15
- Re: regexp repacement, how to present replacement to user?,
Paul Pogonyshev <=
- Re: regexp repacement, how to present replacement to user?, Juri Linkov, 2007/10/16
- Re: regexp repacement, how to present replacement to user?, David Kastrup, 2007/10/17
- Re: regexp repacement, how to present replacement to user?, Paul Pogonyshev, 2007/10/17
- [patch] Re: regexp repacement, how to present replacement to user?, Paul Pogonyshev, 2007/10/20
- Re: [patch] Re: regexp repacement, how to present replacement to user?, Richard Stallman, 2007/10/21
- Re: [patch] Re: regexp repacement, how to present replacement to user?, Paul Pogonyshev, 2007/10/21
- Re: [patch] Re: regexp repacement, how to present replacement to user?, Juri Linkov, 2007/10/21
- Re: [patch] Re: regexp repacement, how to present replacement to user?, Paul Pogonyshev, 2007/10/21
- Re: [patch] Re: regexp repacement, how to present replacement to user?, Stefan Monnier, 2007/10/21
- Re: [patch] Re: regexp repacement, how to present replacement to user?, Richard Stallman, 2007/10/25