From: "David A. Black" Date: 2008-10-01T22:41:03+09:00 Subject: Re: String delete method help Hi -- On Wed, 1 Oct 2008, Keith Johnston wrote: > Hi, > > Yes, that helped. I was able to achieve what I thought the delete > function was doing by using String#sub! with a regular expression to > remove any charaters between "http" and "com". > > string = "http://groups.google.com/group/ruby-talk-google/".sub!(/ > http.*com/, "") It's a bit dangerous to chain sub! (and, indeed, the ! means that this is the dangerous version of sub, so it's always a good idea to check the docs, since "danger" can mean many things). str = "hello".sub!(/x/, 'y') => nil That won't happen with your string but I'd still tend to steer clear of assigning directly from a sub! call. David -- Rails training from David A. Black and Ruby Power and Light: Intro to Ruby on Rails January 12-15 Fort Lauderdale, FL Advancing with Rails January 19-22 Fort Lauderdale, FL * * Co-taught with Patrick Ewing! See http://www.rubypal.com for details and updates!