How to process a long string ( get some parts ? )

if I get the content of a HTML file and put in a string
how can I get all the links inside and store them in array ( or any kind of lists ) ?

I use regular expression , but if I use .match function, the result is “Match” type , I can’t use “gsub” or “sub” to process it

please give me some advice

thank you

Administrator@BOND ~/bin/test
$ cat href.rb

def links(fileName)
text = File.open(fileName) do |f|
f.readlines.join
end

text.scan(/<a\s+href=“([^”]*)"/i) do |m|
puts m[0]
end
end

links(“href.rb”)

END

Administrator@BOND ~/bin/test $ ruby href.rb http://foo.bar http://foo.baz

Administrator@BOND ~/bin/test
$

“RaymondLHW” raymondlhw@sinaman.com schrieb im Newsbeitrag
news:b5cri9$27p391$1@ID-157330.news.dfncis.de

if I get the content of a HTML file and put in a string
how can I get all the links inside and store them in array ( or any kind
of lists ) ?

I use regular expression , but if I use .match function, the result is
“Match” type , I can’t use “gsub” or “sub” to process it

···

please give me some advice

thank you

text.scan … let me try
thank you : )

“Robert Klemme” bob.news@gmx.net wrote in message news:b5cv74$28okso$2@ID-52924.news.dfncis.de

···

Administrator@BOND ~/bin/test
$ cat href.rb

def links(fileName)
text = File.open(fileName) do |f|
f.readlines.join
end

text.scan(/<a\s+href=“([^”]*)"/i) do |m|
puts m[0]
end
end

links(“href.rb”)

END

Administrator@BOND ~/bin/test $ ruby href.rb http://foo.bar http://foo.baz

Administrator@BOND ~/bin/test
$

“RaymondLHW” raymondlhw@sinaman.com schrieb im Newsbeitrag
news:b5cri9$27p391$1@ID-157330.news.dfncis.de

if I get the content of a HTML file and put in a string
how can I get all the links inside and store them in array ( or any kind
of lists ) ?

I use regular expression , but if I use .match function, the result is
“Match” type , I can’t use “gsub” or “sub” to process it

please give me some advice

thank you