[Uw-ruby] I can't seem to get grep to workout with regular strings.
Ryan Davis
ryand-uwruby at zenspider.com
Tue Nov 13 11:51:14 PST 2007
On Nov 12, 2007, at 21:22 , Feng Tien wrote:
> [...]
>
> Using the grep method.
>
> When I use a regular string rather than a regular expression,
> nothing is
> found?
Correct:
% ri grep
-------------------------------------------------------- Enumerable#grep
enum.grep(pattern) => array
enum.grep(pattern) {| obj | block } => array
It takes a regexp. You can make a regex from a string either by
interpolation /#{...}/ or via Regexp.new.
> BTW, for this grep program, it's suppose to output each line that
> has the
> word you're searching for right? Not do a count how many instances?
Correct. it is to act pretty much the same as regular grep, but
awesomer.
More information about the Uw-ruby
mailing list