Ruby Regular Expressions practice non-Greedy quantifiers

Source: Internet
Author: User

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

 

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.