Chinaunix
标题:
sed & awk 的一个sed 问题的困惑。
[打印本页]
作者:
wuxiaobo_2009
时间:
2012-07-29 10:21
标题:
sed & awk 的一个sed 问题的困惑。
原始题目:
I want to see @f1(what will happen) if we put the
font change commands @f1(on a set of lines). If I
understand
things (correctly), the @f1(third) line causes problems.
(No?).
Is this really the case, or is it (maybe) just something
else?
Let's test having two on a line @f1(here) and @f1(there) as
well as one that begins on one line and ends @f1(somewhere
on another line). What if @f1(it is here) on the line?
Another @f1(one).
复制代码
要求把 @f1(内容) 变成\fb内容\fr
如果做练习,作者的这个东东是对的:
# Scribe font change script.
s/@f1(\([^)]*\))/\\fB\1\\fR/g
/@f1(.*/{
N
s/@f1(\(.*\n[^)]*\))/\\fB\1\\fR/g
P
D
}
复制代码
那么,如果在文本的well as one that begins on one line and ends @f1(somewhere之后在插入一行内容,你怎么做到替换成功? 如果这行之前还有@f1()是不是就无解,只能用交互式的进行?
作者:
zooyo
时间:
2012-07-29 10:51
提示:
作者被禁止或删除 内容自动屏蔽
作者:
hbmhalley
时间:
2012-07-29 11:55
@()可能嵌套么?
作者:
wuxiaobo_2009
时间:
2012-07-29 14:02
回复
3#
hbmhalley
嵌套的问题先不考虑。
作者:
wuxiaobo_2009
时间:
2012-07-29 14:24
回复
1#
wuxiaobo_2009
本书后边提到了这个问题郁闷,贴出来:
# Scribe font change script. New and Improved.
:begin
/@f1(\([^)]*\))/{
s//\\fB\1\\fR/g
b begin
}
/@f1(.*/{
N
s/@f1(\([^)]*\n[^)]*\))/\\fB\1\\fR/g
t again
b begin
}
:again
P
D
作者:
hbmhalley
时间:
2012-07-29 17:02
本帖最后由 hbmhalley 于 2012-07-29 17:03 编辑
:1
s/@f1(\([^)]*\))/\\fB\1\\fR/g
/@f1(/!b
s//\\fB/
:2 n;/)/!b2
s//\\fR/;b1
复制代码
要是没嵌套括号的话
作者:
rucypli
时间:
2012-07-29 21:02
真他妈的高深
欢迎光临 Chinaunix (http://bbs.chinaunix.net/)
Powered by Discuz! X3.2