我有一系列的歌曲名称,来自这个subreddit,看起来像这样:
[
"Lophelia -- MYTCH [Acoustic Prog-Rock/Jazz] (2019)",
"Julia Jacklin - Pressure to Party [Rock] (2019)",
"The Homeless Gospel Choir - I'm Going Home [Folk-Punk] (2019) cover of Pat the Bunny | A Fistful of Vinyl",
"Lea Salonga and Simon Bowman - The last night of the world [musical] (1990)",
"$uicideboy$ - Death",
"SNFU -- Joni Mitchell Tapes [Punk/Alternative] (1993)",
"Blab - afdosafhsd (2000)",
"Something strange and badly formatted without any artist [Classical]",
"シロとクロ「ミッドナイトにグッドナイト」(Goodnight to Midnight - Shirotokuro) - (Official Music Video) [Indie/Alternative]",
"Victor Love - Irrationality (feat. Spiritual Front) [Industrial Rock/Cyberpunk]"
...
]
我正在尝试从他们那里解析标题和艺术家,但是我真的在正则表达式方面苦苦挣扎。
我尝试使用来拆分它,"-"但是仅在之后获得艺术家真的很烦人。
我也尝试过使用正则表达式,但实际上无法正常工作。这就是我给艺术家的东西:/(?<= -{1,2} )[\S ]*(?= \[|\( )/i 和标题:的东西/[\S ]*(?= -{1,2} )/i。
每个条目都是一首歌的标题。在歌曲标题之前,可能是歌曲的艺术家,然后是一两个(或三个)破折号。然后,可以在方括号中添加类型,在括号中添加发行日期。我不期望完美的准确性,某些格式可能很奇怪,在那种情况下,我宁愿artist是未定义的,而不是一些奇怪的解析。
举个例子:
[
{ title: "MYTCH", artist: "Lophelia" },
{ title: "Pressure to Party", artist: "Julia Jacklin" },
{ title: "I'm Going Home", artist: "The homeless Gospel Choir" },
{ title: "The last night of the world", artist: "Lea Salonga and Simon Bowman" },
{ title: "Death", artist: "$uicideboy$" },
{ title: "Joni Mitchell Tapes", artist: "SNFU" },
{ title: "afdosafhsd", artist: "Blab" },
{ title: "Something strange and badly formatted without any artist" },
{ title: "Goodnight to midnight", artist: "shirotokuro" }, // Probably impossible with some kind of AI
{ title: "Irrationality" artist: "Victor Love" }
]
慕尼黑5688855
相关分类