作者giacch (小a)
看板RegExp
標題Re: [問題] 抓html tag
時間Sat Nov 8 13:46:02 2008
※ 引述《yingwan (yingwan)》之銘言:
(略過...)
: 我用perl是這樣寫的:
: open(IN, $file) || die "can't read $file";
: @file = <IN>;
undef *TMP;
for(@file) {
$_ = $TMP . $_ if($TMP);
while(/<[^>]+>/) {
push(@TMP, $1) if(s/(<[^>]+>)//);
}
/(<[^>]+)/ ? $TMP = $1 : undef $TMP;
} @file = map { s/ >/>/; s/\n//; s/ +/ /g; $_ } @TMP;
: print "These are the opening tags:\n";
: foreach $line (@file){
: find_opening_tags($line);
(略過...)
加上那一段就會和結果一樣了...
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 118.232.236.185
1F:推 yingwan:你太強了啦,感謝 11/09 08:09