unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Pascal Bourguignon <maps@thalassa.informatimago.com>
Subject: Re: a simple string manipulation
Date: 06 Apr 2003 06:16:49 +0200	[thread overview]
Message-ID: <87vfxs8dla.fsf@thalassa.informatimago.com> (raw)
In-Reply-To: mailman.4152.1049555367.21513.help-gnu-emacs@gnu.org

Luca Ferrari <fluca1978@libero.it> writes:

> Hi to everyone,
> I've got a simple problem (I think) that is related to a string manipulation.
> I must write often strings like this:
> MOVE 	A	TO	B
> 
> and after it's opposite
> MOVE 	B	TO	A
> 
> Now I'd like to know if there's a way to set a key function so that
> after I've  got a group of strings I can simply copy and paste and
> revert they.  Can you shown me how?  Thanks

I would do: 
M-x replace-regexp
MOVE \(.*\) TO \(.*\)
MOVE \2 TO \1

You could put the equivalent into an interactive function:

    ;; untested code follows:
    (defun reverse-moves-region (start end)
        (interactive "*r")
        (goto-char end)
        (insert (buffer-substring start end))
        (goto-char end)
        (while (re-search-forward "MOVE \\(.*\\) TO \\(.*\\)" nil t)
            (replace-match "MOVE \\2 TO \\1")))




        
-- 
__Pascal_Bourguignon__                   http://www.informatimago.com/
----------------------------------------------------------------------
Do not adjust your mind, there is a fault in reality.

  parent reply	other threads:[~2003-04-06  4:16 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <mailman.4152.1049555367.21513.help-gnu-emacs@gnu.org>
2003-04-05 16:36 ` a simple string manipulation Kai Großjohann
2003-04-06  4:16 ` Pascal Bourguignon [this message]
2003-04-05 14:04 Luca Ferrari

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=87vfxs8dla.fsf@thalassa.informatimago.com \
    --to=maps@thalassa.informatimago.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).