Hi --

On Thu, 1 Aug 2002, 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.

Give or take multiline variants, etc., you could do:

  /#{x}.*/.match(y)[0]   # =>"jumped over the lazy dogs back."

To make sure that any regex special characters in x don't get
used as special characters, you could do:

  s = Regexp.escape(x)
  /#{s}.*/.match(y)[0]


David

-- 
David Alan Black
home: dblack / candle.superlink.net
work: blackdav / shu.edu
Web:  http://pirate.shu.edu/~blackdav