all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: "Home_king" <home_king@163.com>
Subject: How to implement such a replace-regexp in interactive mode?
Date: Fri, 12 Mar 2004 22:11:21 +0800 (CST)	[thread overview]
Message-ID: <4051C509.00002E.18145@bj237.163.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 1339 bytes --]

In Dired mode, to modify marked files according to a specified regular expression, as known, push "Q" after you marked them. 
However, I find I can't use "\\1" to quote strings between "\\(" and "\\)" (By the way, strangely, it seems that I must use "\(" and "\)" instead in such "Q" interactive query mode). 
For example, some files has below style:
---------------------------------------
...
aaa
bbb
ccc
... 
---------------------------------------
And I want to add a line "XXX" between "aaa" and "bbb". 
I push "Q" and I use "^\(a+\)$" for regexp parameter and "\1\nXXX" for substitue parameter, but it fails ...

On the other hand, I succedd using my perl script:
-----------------------------------------
#!/usr/bin/perl
($#ARGV <= 0) || print "Your must input filename to process!\n";
open OBJFILE, "$ARGV[0]" or die "$!";
open TMPFILE, ">_tmpfile"; 
while (<OBJFILE>) {
    s/^(bbb$)/$1\nXXX/g;
    select TMPFILE;
    print;
}
`mv -f _tmpfile $ARGV[0] && rm -f _tmpfile`;
-----------------------------------------

Help!

========================================================
是邮件你收 有病毒我上!VIP邮箱 全面保护!            http://vip.163.com

中国最大的免费邮箱在等你 25兆空间4兆附件!      http://mail.163.com

点击网易泡泡惊喜无限 全免费手机短信任你发!      http://popo.163.com

[-- Attachment #2: Type: text/plain, Size: 151 bytes --]

_______________________________________________
Help-gnu-emacs mailing list
Help-gnu-emacs@gnu.org
http://mail.gnu.org/mailman/listinfo/help-gnu-emacs

             reply	other threads:[~2004-03-12 14:11 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-03-12 14:11 Home_king [this message]
  -- strict thread matches above, loose matches on Subject: below --
2004-03-13  6:55 How to implement such a replace-regexp in interactive mode? Home_king

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

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

  git send-email \
    --in-reply-to=4051C509.00002E.18145@bj237.163.com \
    --to=home_king@163.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.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.