2014-09-30 69 views

回答

1

使用拆分来做到这一点。如下所示:

str = "http://siteurl.com/2014/09/net-special-report-9ice-father-of-3-successful-entertainer-with-eyes-on-house-of-reps/" 
#=> "http://siteurl.com/2014/09/net-special-report-9ice-father-of-3-successful-entertainer-with-eyes-on-house-of-reps/" 
a = str.split('/') 
#=> ["http:", "", "siteurl.com", "2014", "09", "net-special-report-9ice-father-of-3-successful-entertainer-with-eyes-on-house-of-reps"] 
a.last 
#=> "net-special-report-9ice-father-of-3-successful-entertainer-with-eyes-on-house-of-reps" 
+0

谢谢。猜我只是懒惰。 – Uchenna 2014-09-30 13:24:13