all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Kai.Grossjohann@CS.Uni-Dortmund.DE (Kai Großjohann)
Subject: Re: replace-match: end of the replacement text for strings
Date: Mon, 16 Sep 2002 21:51:06 +0200	[thread overview]
Message-ID: <vafr8ftd87p.fsf@lucy.cs.uni-dortmund.de> (raw)
In-Reply-To: m3znuh25dh.fsf@tfkp07.physik.uni-erlangen.de

Roland Winkler <Roland.Winkler@physik.uni-erlangen.de> writes:

> "Stefan Monnier <foo@acm.com>" <monnier+gnu.emacs.help/news/@flint.cs.yale.edu> writes:
>
>> >>>>> "Roland" == Roland Winkler <Roland.Winkler@physik.uni-erlangen.de> writes:
>> > When I use replace-match to operate on a string, is there an easy
>> > way to find out the end of the replacement text in the string that
>> > is returned by replace-match (like point in a buffer)? I have in
>> > mind the situation when the optional arg LITERAL is nil, i.e., the
>> > replacement text is `derived' from the string that is passed to
>> > replace-match.
>> 
>> You should be able to get it by looking at the size of the string
>> before and after replacement as well as the size of the replaced
>> text. It's a bit round-about, but I can't think of any other way.
>
> In general, doesn't this work only when I know the replacement text
> -- which I don't know when I have LITERAL set to nil and I am using
> something like "\1" in the replacement?

You need to do some arithmetic to find out the value you want.

length of replaced text = new length of string
                        - old length of string 
                        + length of text to be replaced

kai
-- 
~/.signature is: umop 3p!sdn    (Frank Nobis)

  parent reply	other threads:[~2002-09-16 19:51 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-09-14 22:15 replace-match: end of the replacement text for strings Roland Winkler
2002-09-16 13:43 ` Stefan Monnier <foo@acm.com>
2002-09-16 17:47   ` Roland Winkler
2002-09-16 19:00     ` Stefan Monnier <foo@acm.com>
2002-09-16 19:51     ` Kai Großjohann [this message]
2002-09-16 20:09       ` Roland Winkler

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=vafr8ftd87p.fsf@lucy.cs.uni-dortmund.de \
    --to=kai.grossjohann@cs.uni-dortmund.de \
    /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.