* How to implement such a replace-regexp in interactive mode?
@ 2004-03-12 14:11 Home_king
0 siblings, 0 replies; 2+ messages in thread
From: Home_king @ 2004-03-12 14:11 UTC (permalink / 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
^ permalink raw reply [flat|nested] 2+ messages in thread
* How to implement such a replace-regexp in interactive mode?
@ 2004-03-13 6:55 Home_king
0 siblings, 0 replies; 2+ messages in thread
From: Home_king @ 2004-03-13 6:55 UTC (permalink / raw)
[-- Attachment #1: Type: text/plain, Size: 1304 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 "bbb" and "bbb".
I use "^\(a+\)$" for regexp and "\1\nXXX$" for substitue string, 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收费邮箱两周年超值优惠! 满1赠6!! 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
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2004-03-13 6:55 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-03-12 14:11 How to implement such a replace-regexp in interactive mode? Home_king
-- strict thread matches above, loose matches on Subject: below --
2004-03-13 6:55 Home_king
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).