How to copy string from in a file from some string onward?

Thanks Alan, Dave!

-Kurt

···

-----Original Message-----
From: Alan Chen [mailto:alan@digikata.com]
Sent: Wednesday, July 31, 2002 3:14 PM
To: ruby-talk@ruby-lang.org
Subject: Re: How to copy string from in a file from some string onward?

On Thu, Aug 01, 2002 at 06:58:23AM +0900, Kurt Euler wrote:

All-

I’d appreciate your help on this one:

Please advise as to how I can copy a substring X from string Y starting with string Z through the end of string Y.

For example, supposing I have these strings:

Y = “The quick brown fox jumped over the lazy dogs back.”
Z = “jumped”

I need a routine that will assign to string X the value

“jumped over the lazy dogs back.”

I’ll be putting this code in a script that will process several string Ys consecutively, where string Z is known to occur in each string Y.

Thanks!

-Kurt

x = y.slice(Regexp.new("#{z}.*$"))

There might be a faster way to code it, but this works.


Alan Chen
Digikata LLC