From: "W. James" Date: 2010-01-04T19:50:12+09:00 Subject: Re: Is ruby's regex slower? Ayumu Aizawa wrote: > regex = /href="http:\/\/(.*?)\/.*" target="_blank"/ > > File.open("index.html") do |f| > f.each_line do |c| > puts $1 if c =~ regex > end > end regex = /href="http:\/\/(.*?)\/.*" target="_blank"/ IO.foreach("index.html"){|line| puts $1 if line =~ regex } With no looping: regex = /href="http:\/\/(.*?)\/.*" target="_blank"/ puts IO.readlines("index.html").map{|s| s[ regex, 1 ] }.compact --