On Apr 23, 2006, at 7:21 AM, clc wrote: > I've been using these two lines to capture text that only appears > once, but the second line bothers me a little. Is there a one-line > idiom for this that extracts groups like #scan but returns a string > instead of an array so the second line isn't needed? > > text = string.scan( %r{ skip_this ( keep_this ) skip_this }is ) > text = text[ 0 ] If I understood the question correctly, here are my best ideas: >> str = "skip this find this skip this" => "skip this find this skip this" >> found = str.match(/skip this (find this) skip this/)[1] => "find this" >> another_found = str[/find this/] => "find this" >> yet_another_found = str[/skip this (find this) skip this/, 1] => "find this" Hope that helps. James Edward Gray II