[Top][All Lists]

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

Re: rexexp help needed

From: harven
Subject: Re: rexexp help needed
Date: Fri, 26 Dec 2008 17:54:29 +0100
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.1 (darwin)

henry atting <address@hidden> writes:

> Zitat - Lennart Borgman * Fr Dez 26 2008 um 15:51 -
>> On Fri, Dec 26, 2008 at 3:20 PM, henry atting
>> <address@hidden> wrote:
>>> Hi,
>>> I am trying to build a rexexp that does the following:
>>> I have a text file where I want to replace
>>>    Medicine:One:Two            €12.00
>>> With
>>>    Medicine                    €12.00
>>> Because I have more than one entry `Medicine' (and they
>>> differ slightly, something like `Medicine:Three:Four' and
>>> so on) I have to do it with `quere-replace-regexp'.
>>> With regexp-builder I found this:
>>>    Medicine:.*[^€.0-9]
>>> This works both in regexp-builder and a scratch buffer, but
>>> unfortunately not in a file. If applied on a file replace-regexp
>>> strips everything from the first `:'.

[^€.0-9] matches newline. So it probably takes everything until end of line.
Put a newline in the bracket (input C-q C-j , appears as ^J below).
Also beware of trailing whitespaces. The following works for me, 
with M-x replace-regexp (no query)

Replace regexp:
 \1\,(make-string (length \2) 32)\3

There may be simpler ways to do it (btw 32 is the character code for space)

reply via email to

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