[Top][All Lists]

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

Re: Advanced query-replace-regexp in code

From: Pascal J. Bourguignon
Subject: Re: Advanced query-replace-regexp in code
Date: Wed, 27 May 2009 16:32:07 +0200
User-agent: Gnus/5.101 (Gnus v5.10.10) Emacs/22.2 (gnu/linux)

Nordlöw <address@hidden> writes:

> I can't get the following example to work programmatically.
>   M-x replace-regexp
>   Replace regexp:  \(\w+\)
>   Replace regexp with:  \,(capitalize \1)
> Is this only possible in interactive query-replace?
> If so should I use a combination of while(), looking-at(), re-search-
> forward(), replace-match(), match-string() etc.

Yes, for non-interactive use, it's advised to do

        (while (re-search-forward ...)
           (let ((m1 (match-string ...))
               (delete-region ...)
               (insert (format "%s" (your-sexp m1 ...)))))

__Pascal Bourguignon__

reply via email to

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