[Top][All Lists]

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

Re: How to apply a list of regex replaces to multiple files?

From: David Combs
Subject: Re: How to apply a list of regex replaces to multiple files?
Date: Fri, 1 Aug 2008 08:38:05 +0000 (UTC)

In article <address@hidden>,
Tim X  <address@hidden> wrote:
>"michael.l" <address@hidden> writes:
>> On Jul 1, 1:38 am, "Lennart Borgman (gmail)"
>> <address@hidden> wrote:
>>> michael.l wrote:
>>> > I've browsed the messages here and have googled but don't see a clear
>>> > solution yet. I have about 900 documents to which I need to apply a
>>> > list of maybe 40 separate regex search and replaces. I would like to
>>> > feed a list of the regex expressions and replacements to emacs and
>>> > have it applied to a directory of the files. Any solutions? Keyboard
>>> > macros don't seem like the right solution....
>>> Sounds like the best would be writing a small elisp function to do the job.
>> I'll look into elisp...Struggled with perl to do this....
>Well, not meaning to sound rude, but if you had trouble doing this with
>perl, I suspect you will have even a harder time with elisp. I only say
>this as, from your description, perl would be my first choice and it
>should be pretty straight forward. I personally find perl regexp a lot
>easier to work with and a lot more powerful than elisp's
>implementation. After perl, my second choice would
>likely be sed (actually, sed may be my first choice if you have quite a
>number of regexp because you could put them all in a file and then just
>run sed on the files - essentially, no programming. However, sed can be
>a little tricky to wrap your head around as it has a hell of a lot of
>tcross (at) rapttech dot com dot au

What I used to do is use "ex" (part of vi) or maybe
it was "ed".

Anyway, it had a "source" stmt, ie "source myRegexAndSubstituteCmds.ex",
plus a sh-script

source <something>

source <same thing>


something like that.  Anyway, it worked, for changing variable-names in
about 100 program files, totally hands-off.

Back then perl likely didn't even exist.


reply via email to

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