From: Paul Duncan Date: 2002-07-03T04:35:13+09:00 Subject: Re: grep regex to ruby regex... * Yukihiro Matsumoto (matz@ruby-lang.org) wrote: > Hi, > > In message "grep regex to ruby regex..." > on 02/07/03, Todd Holloway writes: > > |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:]]*$' > > File.foreach(filename) do |line| > next if /^\s*#/ =~ line > next if /^\s*$/ =~ line > print line > end ruby -lne 'print unless /\s*#/ or !/\S/' filename I'm golfing with the champ! :D > matz. -- Paul Duncan pabs in #gah (OPN IRC) http://www.pablotron.org/ OpenPGP Key ID: 0x82C29562