Perlを使用してテキストファイルを解析したい。このテキストファイルには、次のようなHTMLファイルのログが含まれています。HTMLログファイルを解析して特定のフォーマットのテキストファイルを取得する
Details from /projects/git/Changelog.html file:
NEW_FEATURES: <a href="http://jira.xyz.com/browse/JIRA-4208">JIRA-4208</a><span style='mso-spacerun:yes'> </span>Add New Config C support in code
BUG_FIX: <a href="http://jira.xyz.com/browse/BUGJIRA-31">BUGJIRA-31</a><span style='mso-spacerun:yes'> </span>Bugfix of some old bug
NEW_FEATURES: <a href="http://jira.xyz.com/browse/ZEERA-273">ZEERA-273</a><span style='mso-spacerun:yes'> </span>Add support for some other feature.
Details from /projects/git/Changelog2.html file:
BUG_FIX: <a href="http://jira.xyz.com/browse/BUGJIRA-33">BUGJIRA-33</a><span style='mso-spacerun:yes'> </span>Bugfix of an issue
NEW_FEATURES: <a href="http://jira.xyz.com/browse/JIRA-4209">JIRA-4209</a><span style='mso-spacerun:yes'> </span>Add New Config D support in code
各行には、バグ番号とその説明が含まれています。その説明に続いて
JIRA-4208, BUGJIRA-31, ZEERA-273, BUGJIRA-33, JIRA-4209 : Add New Config C support in code, Bugfix of some old bug, Add support for some other feature, Bugfix of an issue, Add New Config D support in code
すなわち、すべてのバグ番号:
は、解析した後、予想される出力は下の通りです。
私は別のファイルに出力を書きたい可能であればoutput.txt
EDIT-1:
私のコードは下の通りです:
#!/usr/bin/perl
open (FILE, 'input_file1.txt') or die "Could not read from file, exit...";
while(<FILE>)
{
chomp;
($junk0,$junk1,$junk2,$junk3,$junk4,$BUG_NUMBR) = split /[:<="">]+/,$_;
print "$BUG_NUMBR \n";
}
close FILE;
exit;
、出力は次のとおりです。
JIRA-4208
BUGJIRA-31
ZEERA-273
BUGJIRA-33
JIRA-4209
これは、次のように期待される出力とは大きく異なります。abo ve。私は予想される出力の2番目の部分に適切な正規表現を定義できません。これはバグの簡単な説明です。
あなたは何を試してみましたか?あなたのコードではうまくいかないのですか?ここで質問は何ですか? –
@ChrisDoyle:サンプルコードを追加し、制限事項についても説明しました。親切にソリューションの提案をお願いします。 – Yash
本当にすべてのバグ番号のリストが必要ですか?すべての説明のリストが続きますか? –