[英]How do I match seasons/episodes against a string in Ruby?
I need to find out if a variable includes S00E00
when the numbers are unknown. 当数字未知时,我需要找出变量是否包括
S00E00
。 I have tried a lot of different things and I can identify both the letters and numbers, but only separately. 我尝试了很多不同的方法,并且可以同时识别字母和数字,但只能分别识别。 Basically what I need is to identify whether a file is a tv-show or not from standard naming as defined here: https://support.plex.tv/hc/en-us/articles/200220687-Naming-Series-Season-Based-TV-Shows .
基本上,我需要根据此处定义的标准命名来确定文件是否为电视节目: https : //support.plex.tv/hc/en-us/articles/200220687-Naming-Series-Season-基于电视节目 。
You can use the following expression: 您可以使用以下表达式:
/
\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
For example: 例如:
str = 'Heroes - s01e02 - The Coming Storm.avi'
str.match /\bs\d{2}e\d{2}\b/i
#=> #<MatchData "s01e02">
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.