关键词为选择形式,如 abc|123 ,连续出现3次abc或者连续出现3次123都匹配,另外如 abc123abc, 123abcabc, 123123abc等都算匹配。
试验文本文档内容为:
cat ./123.txt
abcabcabcabc
12ab1ab1abc
abc123abc
123abcabc
123 123123
perl脚本1.pl内容为:
#! /usr/bin/perl
$what = 'abc|123';
while (<>) {
if (/($what){3}/) {
print;
}
}
运行脚本: perl 1.pl ./123.txt
结果为:
abcabcabcabc
abc123abc
123abcabc
试验文本文档内容为:
cat ./123.txt
abcabcabcabc
12ab1ab1abc
abc123abc
123abcabc
123 123123
perl脚本1.pl内容为:
#! /usr/bin/perl
$what = 'abc|123';
while (<>) {
if (/($what){3}/) {
print;
}
}
运行脚本: perl 1.pl ./123.txt
结果为:
abcabcabcabc
abc123abc
123abcabc
编辑回复