0
我需要找出一個變量在數字未知時是否包含S00E00
。我嘗試了很多不同的東西,我可以識別字母和數字,但只能分開。基本上我需要的是從這裏定義的標準命名中識別文件是否是電視節目:https://support.plex.tv/hc/en-us/articles/200220687-Naming-Series-Season-Based-TV-Shows。如何根據Ruby中的字符串匹配季節/劇集?
我需要找出一個變量在數字未知時是否包含S00E00
。我嘗試了很多不同的東西,我可以識別字母和數字,但只能分開。基本上我需要的是從這裏定義的標準命名中識別文件是否是電視節目:https://support.plex.tv/hc/en-us/articles/200220687-Naming-Series-Season-Based-TV-Shows。如何根據Ruby中的字符串匹配季節/劇集?
可以使用下面的表達式:
/
\b # word boundary
s # letter s
\d{2} # exactly 2 digits
e # letter e
\d{2} # exactly 2 digits
\b # word boundary
/ix # case- and space-insensitive matching
例如:
str = 'Heroes - s01e02 - The Coming Storm.avi'
str.match /\bs\d{2}e\d{2}\b/i
#=> #<MatchData "s01e02">
1分手的正則表達式和說明每個部件。 – thohl 2014-10-30 16:48:31