大家好!
         我有个文本,类似附件中的样子,我要的匹配项包括ip及<eid>标签中还有(B的内容知道</c>结束的这段日志。
以下是我的脚本,但是只能匹配到第1次的匹配项,以后的就匹配不到了,很是郁闷,各位帮我看看!

#!/usr/bin/perl -w
use strict;
open(L,'c:\\symbian.log') or die('Can not open this file!');
$/=undef;
my $a=<L>;
close(L);
$a=~/((\[ip 
=\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\])\<c\>\n\<srqh\>\n[^\n]+\n[^\n]+\n[^\n]+\n\<\/srqh\>\n\<nd\>\n\<eid\>(.*?)\(B(.*?)\<\/eid\>\n\<whead\>(.*?)\<\/whead\>\n\<wbody\>(.*?)\<\/wbody\>(.*?)\<\/c\>)/sg;
print "============================================================\n";
print "$2\n";
print "----------------------------------\n";
print "$1\n";
print "============================================================\n";


不甚感激!

2010-08-17 



[email protected] 

-- 
您收到此邮件是因为您订阅了 Google 网上论坛的“PerlChina Mongers 讨论组”论坛。
要向此网上论坛发帖,请发送电子邮件至 [email protected]。
要取消订阅此网上论坛,请发送电子邮件至 [email protected]。
若有更多问题,请通过 http://groups.google.com/group/perlchina?hl=zh-CN 访问此网上论坛。

Attachment: fff.log
Description: Binary data

回复