From: Phrogz Date: 2008-01-13T11:15:25+09:00 Subject: Re: Simple Regex help On Jan 12, 6:37 pm, "itsme213" wrote: > I have a file of code that has "!"-delimited lines and other non !-delimited > lines. I want to remove all the "!"-delimited lines > > !some stuff that i do not want! > > lots of other stuff that i want > lots of other stuff that i want > > !some stuff that i do not want! > > lots of other stuff that i want > lots of other stuff that i want > > What would be a simple ruby script to use regex and remove all the >   !....! IO.readlines( 'file.txt' ).delete_if{ |line| line =~ /^!.*!$/ } #=> returns an array; you may want to .join it with the newline seperator.