看板 Linux 關於我們 聯絡資訊
#!/usr/bin/env perl # It reads from STDIN while ($string=<STDIN>) { # push $string to @lines until reach numbers push @lines, $string and next unless $string =~ /^\d+/; # print @lines if last element is 'ccc' print @lines if $lines[$#lines] =~ /ccc/; # reset @lines with first element as numbers @lines = ($string); } # handle end of file print @lines if $lines[$#lines] =~ /ccc/; Perl 處理文字真的超強,不考慮學一下嗎?XD -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 68.181.7.7
asadfish:Perl 推一個XDDDDDDDDD 02/22 08:57
losepacific:perl -ne 'BEGIN{undef $/}; 02/22 19:44
losepacific:print "$1\n" while /(\d+\/\d+[^\d]*ccc)/sg' 檔案 02/22 19:45
Sizemore24:Perl 處理這類問題真的看來超強。 02/23 00:31