Here we mainly use non-Greedy quantifiers. +? "Means matching any character until the first character is met"
In addition, find the matched group, as shown in figure X [0].
Require 'open-Uri 'Open ('HTTP: // railslab.newrelic.com/category/masters-interviews') Do | f | S = "F. each {| Line | S <line} URLs = S. scan (/"(http: \/content.newrelic.com \/railslab \/videos \/. + ?) "/) URLs. Each {| x | puts X [0]. to_s} End
The result is that all the masters-interviews series in rialslab are obtained.
Http://content.newrelic.com/railslab/videos/railslab-rightscale-cloud-considerations-070109.mov
Http://content.newrelic.com/railslab/videos/railslab-rightscale-cloud-considerations.m4v
Http://content.newrelic.com/railslab/videos/railslab-heroku-tools-collaboration.mov
Http://content.newrelic.com/railslab/videos/railslab-heroku-tools-collaboration.m4v
Http://content.newrelic.com/railslab/videos/railslab-heroku-performance-bp.mov
Http://content.newrelic.com/railslab/videos/railslab-heroku-performance-bp.m4v
Http://content.newrelic.com/railslab/videos/railslab-heroku-intro-vision.mov
Http://content.newrelic.com/railslab/videos/railslab-heroku-intro-vision.m4v
Http://content.newrelic.com/railslab/videos/railslab-bbg-jproudman-pt2.mov
Http://content.newrelic.com/railslab/videos/railslab-bbg-jproudman-pt2.m4v
Http://content.newrelic.com/railslab/videos/railslab-bbg-jproudman-pt1.mov
Http://content.newrelic.com/railslab/videos/railslab-bbg-jproudman-pt1.m4v
Http://content.newrelic.com/railslab/videos/railslab-productmadness-1.mp3
Http://content.newrelic.com/railslab/videos/railslab-productmadness-2.mp3
Http://content.newrelic.com/railslab/videos/railslab-cunningham-mastery.m4v
Http://content.newrelic.com/railslab/videos/railslab-37signals-imbriaco2.m4v