[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Can't get replace-match to replace intended match-data
From: |
Ehud Karni |
Subject: |
Re: Can't get replace-match to replace intended match-data |
Date: |
Sat, 29 Sep 2001 22:13:02 +0200 |
On Sat, 29 Sep 2001 20:54:33 +0200 (MET DST), Jonas Jarnestrom
<erajonj@ki.ericsson.se> wrote:
>
> #######################################################################
> #
> # Target: <cpmerge_dir>
> # Doc: <bla bla bla bla>
> #
> # Type: <user config>
>
> I want to replace the contents in between the first brackets with the
> function:
>
> (defun cs-head-set-target ()
> ""
> (interactive)
> (goto-char (point-min))
> (and (re-search-forward "Target: +<\\(.*\\)>" 400 'noerr)
^
change the . to [^>] here-----+
> (replace-match "perka" nil nil nil 1))
> )
Regular expressions matches the MAXIMUM possible string. If your search
was not limited to 400 characters, Your expression would have taken
from the 1st "Target: <" up to the last ">" in your file.
Ehud.
--
Ehud Karni Mivtach - Simon Insurance /"\
Tel: +972-3-7966-561 Fax: +972-3-7966-667 \ / ASCII Ribbon Campaign
(USA) Fax and voice mail: 1-815-5509341 X Against HTML Mail
Better Safe Than Sorry / \
mailto:ehud@unix.simonwiesel.co.il http://www.simonwiesel.co.il