From: Reimer Behrends Date: 2002-08-01T21:01:49+09:00 Subject: Re: How to copy string from in a file from some string onward? Mauricio Fern�ndez (batsman.geo@yahoo.com) wrote: > On Thu, Aug 01, 2002 at 06:58:23AM +0900, Kurt Euler wrote: [...] > > Please advise as to how I can copy a substring X from string Y > > starting with string Z through the end of string Y. > > Yet another: > > x = y[(y =~ /#{z}/)..-1] Does not work reliably if 'z' contains special regular expression characters such as '.': irb(main):001:0> z = "." "." irb(main):002:0> y = "alpha.beta." "alpha.beta." irb(main):003:0> x = y[(y =~ /#{z}/)..-1] "alpha.beta." You want to use String#index, e.g. x = y[y.index(z)..-1] Reimer Behrends