file.grep? I checked that grep is a method of Enumerable. is it suitable for
file? if so, it is a class method or instance method?
Tks.
Shannon
···
From: Emmanuel Touzery emmanuel.touzery@wanadoo.fr
Reply-To: ruby-talk@ruby-lang.org
To: ruby-talk@ruby-lang.org (ruby-talk ML)
Subject: Re: Conditional block operations
Date: Tue, 3 Dec 2002 23:44:50 +0900Emmanuel Touzery wrote:
Shannon Fang wrote:
I think for this case, the easist way might be
file.each do |line|
a, b = line.split(pattern) if line !~ /^\s*$/
endgrep could help, unfortunately I don’t know if it can be negated (eg “all
but the matches”).emmanuel
actually \S is “non whitespace character”, so this is ok:
file.grep /^\S+$/ do |line|
a, b = line.split pattern
endemmanuel
“If someone breaks into my house and steals my CDs,
who calls the cops, me or the music industry?
If it’s me, then that’s my property.” --Ruben Safir
Add photos to your e-mail with MSN 8. Get 2 months FREE*.
http://join.msn.com/?page=features/featuredemail