From: Andreas Politz <politza@fh-trier.de>
To: help-gnu-emacs@gnu.org
Subject: Re: Utilizing Regexp (or something else) to replace an arbitrary string length of the same character with the same string length of another character.
Date: Fri, 28 Nov 2008 01:01:28 +0100 [thread overview]
Message-ID: <1227830556.39828@arno.fh-trier.de> (raw)
In-Reply-To: <mailman.1392.1227828233.26697.help-gnu-emacs@gnu.org>
Peter Dyballa wrote:
>
> Am 27.11.2008 um 21:24 schrieb Tim Visher:
>
>> The issue is that I use the characters I want to replace
>> at other locations where I don't want them replaced.
>
> You can mark a region. This will restrict substitutions to happen only
> inside the marked region.
>
> --
> Greetings
>
> Pete
>
> Remember: use logout to logout.
>
>
>
>
I guess this regexp will never match
\(.\)\1*\=\1*
Maybe this will:
(defun replace-chars-around-point (new-char)
"Replace all occurences of char at, before and after point with
NEW-CHAR."
(interactive (list
(read-char
(format "Replace %s with: "
(thing-at-point 'char)))))
(let ((p (point)) ;save-excursion does not work here
(char (thing-at-point 'char)))
(if (not char)
(error "Buffer is empty"))
(skip-chars-backward char)
(re-search-forward (format "%s+" char))
(replace-match (make-string (- (match-end 0)
(match-beginning 0)) new-char))
(goto-char p)))
-ap
next prev parent reply other threads:[~2008-11-28 0:01 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <mailman.1299.1227715545.26697.help-gnu-emacs@gnu.org>
2008-11-26 17:25 ` Utilizing Regexp (or something else) to replace an arbitrary string length of the same character with the same string length of another character Xah Lee
2008-11-27 20:24 ` Tim Visher
2008-11-27 23:23 ` Peter Dyballa
[not found] ` <mailman.1392.1227828233.26697.help-gnu-emacs@gnu.org>
2008-11-28 0:01 ` Andreas Politz [this message]
2008-11-28 1:01 ` tyler
2008-11-26 14:41 Tim Visher
2008-11-26 16:31 ` Peter Dyballa
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1227830556.39828@arno.fh-trier.de \
--to=politza@fh-trier.de \
--cc=help-gnu-emacs@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.