unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: "Tim Visher" <tim.visher@gmail.com>
To: "Xah Lee" <xahlee@gmail.com>
Cc: help-gnu-emacs@gnu.org
Subject: Re: Utilizing Regexp (or something else) to replace an arbitrary string length of the same character with the same string length of another character.
Date: Thu, 27 Nov 2008 15:24:28 -0500	[thread overview]
Message-ID: <c115fd3c0811271224y3260d26eo4345c43ab141dff8@mail.gmail.com> (raw)
In-Reply-To: <ac2d972b-c7e5-4403-bc91-1c50fa5d69df@r15g2000prh.googlegroups.com>

Yeah, I did consider using replace-string and query-replace-string and
their ilk.  The issue is that I use the characters I want to replace
at other locations where I don't want them replaced.  Also, I want to
replace an arbitrary amount of them at one time.  I actually already
did the edits that I want done by using query-replace-string.
However, if the document had been much longer, that really would've
taken too long.  It doesn't sound like there's a quick way to do this
in Emacs.  Oh well.

Thanks anyway.

On Wed, Nov 26, 2008 at 12:25 PM, Xah Lee <xahlee@gmail.com> wrote:
> On Nov 26, 6:41 am, "Tim Visher" <tim.vis...@gmail.com> wrote:
>> Hello Everyone,
>>
>> I have a bunch of arbitrarily long strings of '=' characters and I
>> would like to replace them one for one with '-' characters.  I know I
>> could do this with a simple find and replace using isearch, but that
>> would require me going through them one at a time.  I'm wondering if
>> there's a way to do this with a regex such as:
>>
>>     r/(=+)/-{length of n}
>>
>> Obviously that's a major bastardization of syntax and doesn't really
>> exist in any language, but I figure this should be able to be done in
>> Emacs somehow.
>
> if your question is about interactive use, then you can use
>
> query-replace
> query-replace-regexp
>
> after you type the find string and replace string, you can just type
> "!" to replace them all in one shot in the current buffer.
>
> If you don't want it to promp you on the first finding, you can call
> replace-string instead.
>
> If your question is about doing the replacement on whole directory of
> files, you can mark the files in dired and then invoke dired-do-query-
> replace-regexp.
>
> See:
>
> • Find and Replace with Emacs
>  http://xahlee.org/emacs/emacs_find_replace.html
>
> • Interactively Find and Replace String Patterns on Multiple Files
>  http://xahlee.org/emacs/find_replace_inter.html
>
> If your question is about writing a lisp program so that you can press
> a button to do all the replacement you want without needing to answer
> prompt bout find/replace string, on a single file or bunch of files,
> it's very easy too. See for example:
>
> • Elisp Lesson: Repeated Find Replace
>  http://xahlee.org/emacs/elisp_repeat_replace.html
>
>> In Christ,
>
> • Has Religion Made Useful Contributions to Civilization?
>  http://xahlee.org/p/religion_Russell.html
>
>  Xah
> ∑ http://xahlee.org/
>
> ☄
>



-- 

In Christ,

Timmy V.

http://burningones.com/
http://five.sentenc.es/ - Spend less time on e-mail

  reply	other threads:[~2008-11-27 20:24 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <mailman.1299.1227715545.26697.help-gnu-emacs@gnu.org>
2008-11-26 17:25 ` Utilizing Regexp (or something else) to replace an arbitrary string length of the same character with the same string length of another character Xah Lee
2008-11-27 20:24   ` Tim Visher [this message]
2008-11-27 23:23     ` Peter Dyballa
     [not found]     ` <mailman.1392.1227828233.26697.help-gnu-emacs@gnu.org>
2008-11-28  0:01       ` Andreas Politz
2008-11-28  1:01     ` tyler
2008-11-26 14:41 Tim Visher
2008-11-26 16:31 ` Peter Dyballa

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=c115fd3c0811271224y3260d26eo4345c43ab141dff8@mail.gmail.com \
    --to=tim.visher@gmail.com \
    --cc=help-gnu-emacs@gnu.org \
    --cc=xahlee@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).