标签: python regex
我需要以Some title (season 1, episode 2),Some title (season 1;episode 2)或Some data (season 1)格式分析具有大量电视节目的文本文件。 我使用此正则表达式来匹配季节和剧集season (?<season>\d{1,2})[,; ]+episode (?<episode>\d{1,2}),但我不知道如何使剧集匹配为可选(如果没有剧集,则仅匹配季节)。
Some title (season 1, episode 2)
Some title (season 1;episode 2)
Some data (season 1)
season (?<season>\d{1,2})[,; ]+episode (?<episode>\d{1,2})