From: Mike Fletcher Date: 2006-05-04T08:35:07+09:00 Subject: Re: html stringScanner regexp Tomas Fischer wrote: [...] > > ScannerScan.scan(/.*class=title>(.*)<\/a><\/div>_NEWLINE_/) But I get > only the last title -- title4. Why? Is the regex wrong, or do I miss the > point with the scan method? The .* is greedy and gobbles up as much of the source as it can (up to the end of the string) and then the regex engine backtracks just enough to match the last occurance. You might try this instead: %r{ class=title>(.*?)\n} But remember that unless you can guarantee the formatting of your input won't vary much you're probably better off using a proper HTML parser to handle HTML rather than regexen. -- Posted via http://www.ruby-forum.com/.