From: franco Date: 2007-12-02T01:34:59+09:00 Subject: Re: regex problem On Nov 27, 12:00 pm, Christian von Kleist wrote: > On Nov 27, 2007 11:28 AM, K. R. wrote: > > > > > hi @all > > > I would like to scan a string of html-tags. I need it to take out all > > links (a-tags) in the string, but I become only the last one. What is > > wrong? See the code below... > > > response = 'test1 - > href="hello2.html">test2' > > response.scan(/ > puts line > > end but what if href is not the first attribute of ? > > > thanks for helping! > > -- > > Posted viahttp://www.ruby-forum.com/. > > Franco is right. You could fix it by doing "a.*?href". However, I > would change "a.*href" to "a\s+href" since you're looking for any > amount of whitespace after the "a" and before the "href". > > response = 'test1 - test2' > response.scan(/ puts line > end