[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Another replace regexp with list question
From: |
Barry Margolin |
Subject: |
Re: Another replace regexp with list question |
Date: |
Mon, 10 Jun 2013 01:10:30 -0400 |
User-agent: |
MT-NewsWatcher/3.5.3b3 (Intel Mac OS X) |
In article <mailman.1310.1370826222.22516.help-gnu-emacs@gnu.org>,
Leandro Marcolino <leandromarcolino@gmail.com> wrote:
> Hello, everyone!..
>
> This time I am trying to find occurrences of:
>
> "<span style='color:white'>私私私私</span>", but
> the number of 私 can change from 1 to many.
>
> And I want to replace each 私 of the list to a white space (besides
> removing the <span> clause). So, if there were x "私", I need x " ".
> Is it possible to do this using replace-regexp?.. Of course I can't just
> look for "私" and replace to " ", because I have occurrences of
> "私" that are not inside the group "<span
> style='color:white'></span>".
>
> I tried something like "<span style='color:white'>\(\(私\)+\)</span>
> -> \,(cond (\1 " ")))", but then I lose the information of how many
> "私" were there, and everything changes to a single " "....
>
> Thanks for your help!.. :)
>
> Regards,
> Leandro
Regular expressions can't count.
I would do it with a keyboard macro. Search for the span, mark it as a
region, narrow to region, use replace-string to replace each 私
with space, widen.
--
Barry Margolin, barmar@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***