perl中的ANSI不能高亮显示啊?
时间:2011-04-13
来源:互联网
这是《精通正则表达式》第三版上的一个例子,运行后不行啊。大侠们看看什么原因?
$/=".\n";
while(<>){
next unless s{
\b
([a-z]+)
(
(?:
\s
|
<[^>]+>
)+
)
(\1\b)
}
{\e[7m$1\e[m\e[7m$2\e[m\e[7m$3\e[m}igx;
s/^(?:[^\e]*\n)+//mg;
s/^/$ARGV: /mg;
print;
}
测试文件如下:
check for double words(such as this this).
Find you are a a beautiful girl.
Thanks to your help help.
Do you like me me?I think so so.
1234566778899.
123456789a
运行结果如下:
doubleword.txt: check for double words(such as [7mthis[m[7m [m[7mthis[m).
doubleword.txt: * Find you are [7ma[m[7m [m[7ma[m beautiful girl.
doubleword.txt: Thanks to your [7mhelp[m[7m [m[7mhelp[m.
doubleword.txt: Do you like [7mme[m[7m [m[7mme[m?I think [7mso[m[7m [m
[7mso[m.
系统为windows sp3,perl版本为 strawberry5.8.8
$/=".\n";
while(<>){
next unless s{
\b
([a-z]+)
(
(?:
\s
|
<[^>]+>
)+
)
(\1\b)
}
{\e[7m$1\e[m\e[7m$2\e[m\e[7m$3\e[m}igx;
s/^(?:[^\e]*\n)+//mg;
s/^/$ARGV: /mg;
print;
}
测试文件如下:
check for double words(such as this this).
Find you are a a beautiful girl.
Thanks to your help help.
Do you like me me?I think so so.
1234566778899.
123456789a
运行结果如下:
doubleword.txt: check for double words(such as [7mthis[m[7m [m[7mthis[m).
doubleword.txt: * Find you are [7ma[m[7m [m[7ma[m beautiful girl.
doubleword.txt: Thanks to your [7mhelp[m[7m [m[7mhelp[m.
doubleword.txt: Do you like [7mme[m[7m [m[7mme[m?I think [7mso[m[7m [m
[7mso[m.
系统为windows sp3,perl版本为 strawberry5.8.8
作者: 小perl 发布时间: 2011-04-13
回复 小perl
在 Linux 下测试正常。程序本身没问题。问题的关键在于终端模拟器是否支持颜色序列,以及支持的标准是怎样的。
Windows 的 CMD 应该是不支持颜色序列的吧,PowerShell 应该支持颜色,但是是否支持与 Linux 终端同样的颜色序列就不清楚了(因为我不使用 Windows)。
在 Linux 下测试正常。程序本身没问题。问题的关键在于终端模拟器是否支持颜色序列,以及支持的标准是怎样的。
Windows 的 CMD 应该是不支持颜色序列的吧,PowerShell 应该支持颜色,但是是否支持与 Linux 终端同样的颜色序列就不清楚了(因为我不使用 Windows)。
作者: Monox 发布时间: 2011-04-13
相关阅读 更多
热门阅读
-
office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具
阅读:74
-
如何安装mysql8.0
阅读:31
-
Word快速设置标题样式步骤详解
阅读:28
-
20+道必知必会的Vue面试题(附答案解析)
阅读:37
-
HTML如何制作表单
阅读:22
-
百词斩可以改天数吗?当然可以,4个步骤轻松修改天数!
阅读:31
-
ET文件格式和XLS格式文件之间如何转化?
阅读:24
-
react和vue的区别及优缺点是什么
阅读:121
-
支付宝人脸识别如何关闭?
阅读:21
-
腾讯微云怎么修改照片或视频备份路径?
阅读:28