From: "G.Durga Prasad" Date: 2008-10-18T18:15:30+09:00 Subject: Re: Shoes GUI - downloading site, using reg exs on body ------=_Part_131790_22920113.1224321375694 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline On Sat, Oct 18, 2008 at 5:03 AM, Double Minus wrote: > It is working - I guess I just don't understand how... > > It prints some numbers into the @results para. I want to find and pull > links out of the body text. I was starting with a very basic search, to > just try to have it pull out every line with "http" in it. > > (/^*http\/$/) doesn't work for my reg ex > > I get: > > rb:23: invalid regular expression; there's no previous pattern, to which > '*' would define cardinality at 2: /^*http\/$/ > > double > > And why: thank you for this amazing, fun learning tool. It has been > invaluable in figuring out what Ruby is all about. > -- > Posted via http://www.ruby-forum.com/. > > I took this as an exercise and here is what I came up with: Shoes.app do stack :left => 65, :top => 75 do @results = para "results" end stack :left => 165, :top => 180 do para "URL:" flow do button "Clear" do @status.replace "results cleared..." and @searching.replace " " and @results.replace "results" end @url = edit_line "http://www.google.com/" button "OK" do stack do @searching = title "Searching site", :size => 16 @status = para "One moment..." download @url.text do |site| @searching.replace "Results" @results.replace "" content = site.response.body.inspect array = content.split(/\"/).map{|e| e.chop } @status.text = array.grep(/^http/).join("\n") end end end end end end ------=_Part_131790_22920113.1224321375694--