2014-10-29 24 views

回答

4

可以使用下面的表達式:

/ 
    \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"> 
+0

1分手的正則表達式和說明每個部件。 – thohl 2014-10-30 16:48:31

相關問題