From: Dossy Date: 2002-07-03T02:02:54+09:00 Subject: Re: grep regex to ruby regex... On 2002.07.03, Todd Holloway wrote: > > I'm just about to finish up my first ruby program, but I'm > stuck on one last part...I need equivlent of the below in ruby: > > grep -v "^[[:space:]]*#" filename | grep -v '^[[:space:]]*$' > > thanks in advance! I will send out final program once it's > done. $ cat <<-EOT >foo.rb filename = ARGV[0] # this is a test File.open(filename) { |file| # some more test file.each_line { |line| # this shouldn't get removed next if line =~ /^\s*#/ next if line =~ /^\s*$/ puts line } } EOT $ ruby foo.rb foo.rb filename = ARGV[0] File.open(filename) { |file| file.each_line { |line| # this shouldn't get removed next if line =~ /^\s*#/ next if line =~ /^\s*$/ puts line } } $ That help? -- Dossy -- Dossy Shiobara mail: dossy@panoptic.com Panoptic Computer Network web: http://www.panoptic.com/ "He realized the fastest way to change is to laugh at your own folly -- then you can let go and quickly move on." (p. 70)