[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: rexexp help needed
From: |
Lennart Borgman |
Subject: |
Re: rexexp help needed |
Date: |
Fri, 26 Dec 2008 18:11:54 +0100 |
On Fri, Dec 26, 2008 at 5:17 PM, henry atting
<nspm_01@literaturlatenight.de> wrote:
> Zitat - Lennart Borgman * Fr Dez 26 2008 um 15:51 -
>
>> On Fri, Dec 26, 2008 at 3:20 PM, henry atting
>> <nspm_01@literaturlatenight.de> 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 `:'.
>>
>> You have to escape the [] with \. That is a bit tricky since you have
>> to double the escape character. (One for text escaping, one for regexp
>> char escaping.)
>
>
> Mmh, IIRC I tried it already with escape sequences. Anyway, if I do so I
> get:
>
> Replaced 0 occurences
>
> No difference if I try it in a scratch buffer or a file.
> Without escaping it works in a scratch buffer at least. ;)
Eh, sorry. Everything (nearly) I wrote before was wrong. You do not
need to escape []. Something like this is what you want
(re-search-forward "Medicine:[^€]*")