From: Lars Haugseth Date: 2008-10-01T22:04:01+09:00 Subject: Re: String delete method help * Keith Johnston wrote: > > Hi, > > I have a string which hold a URL. I'm trying to use the string .delete > method to remove the domain from the url but it isn't working as I > thought it should from the docs. > > For example: > > string = "http://groups.google.com/group/ruby-talk-google/" > > I want to remove the "http://groups.google.com" part of the string, so > I tried: > > string.delete('http', 'com') No need to reinvent the wheel: require 'uri' uri = URI.parse('http://groups.google.com/group/ruby-talk-google/') puts uri.path http://www.ruby-doc.org/stdlib/libdoc/uri/rdoc/classes/URI.html -- Lars Haugseth "If anyone disagrees with anything I say, I am quite prepared not only to retract it, but also to deny under oath that I ever said it." -Tom Lehrer