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

--