私は切り取ってジョージマイケルのDVDトラックリストをAmazonから$str
で、その後のコードを最初の2桁とそれ以外で分割して処理します:1つの線を2つの部分に分割する
$str = "20 Fastlove 21 Jesus To A Child 22 Spinning the Wheel 23 Older 24 Outside 25 As (with Mary J. Blige) 26 Freeek! 27 Amazing 28 John and Elvis are Dead 29 Flawless (Go To The City) 30 Shoot The Dog 31 Roxanne 32 An Easier Affair 33 If I Told You That (with Whitney Houston) 34 Waltz Away Dreaming 35 Somebody To Love 36 I Can’t Make You Love Me 37 Star People '97 38 You Have Been Loved 39 Killer/ Papa Was A RollIn Stone 40 Round Here";
while ($str =~ /(\d{2}) (\S+)/g) {
print "$1 $2\n";
}
結果:
20 Fastlove
21 Jesus
22 Spinning
23 Older
24 Outside
25 As
26 Freeek!
27 Amazing
28 John
29 Flawless
30 Shoot
31 Roxanne
32 An
33 If
34 Waltz
35 Somebody
36 I
37 Star
97 38
39 Killer/
40 Round
上記の種類の作品は、フルトラック名は含まれていません。私が望む結果を得る方法についてのアドバイスはありますか?私が期待している、または望む結果は次のとおりです。
20 Fastlove
21 Jesus To A Child
22 Spinning the Wheel
[etc.]
質問を理解できません。 – tchrist
曲名に数字が表示されないようにすることはできません。 –
情報のためにAmazonを盗むのではなく、CDDBのようなトラック情報のデータベースを使用してみませんか? – Ether