From: Florian Gilcher Date: 2009-11-28T16:47:21+09:00 Subject: Re: where is grep? On Nov 28, 2009, at 3:57 AM, David A. Black wrote: >> The same can be done in Ruby 1.9 by just splitting the String >> beforehand. Arrays are Enumerable and thus >> still have grep: >> >> x = "hello\nworld\nbaby\ngirl" >> x.split("\n").grep(/hello/) >> #=> ["hello"] >> >> Note the absence of the line-break which might be intended or not :). > > I would probably do this in 1.9: > > string.lines.grep(/pattern/) > > where lines returns an enumerator. > > > David Jep, there is always room to improve. It also maps better to the old behaviour where you were basically grepping #each_line. Thanks, Florian