String search backwards?

n = orig_str.rindex(sub_str)

Does it help?
Gennady.

···

-----Original Message-----
From: list-bounce@example.com [mailto:list-bounce@example.com] On Behalf
Of Toby DiPasquale
Sent: Tuesday, January 24, 2006 12:06
To: ruby-talk ML
Subject: String search backwards?

Hi all,

Can Ruby search a string backwards? I can't find any reference to this
in the docs or online, but it seems as if you should be able to do this.

What I would like, ideally, is a method like:

n = rstrstr( orig_str, sub_str)

where n is the starting index of the last occurrence of sub_str in
orig_str. Anybody know how to do this? I tried using the 'r' modifier to
// but that failed as well.

--
Posted via http://www.ruby-forum.com/.

Gennady Bystritsky wrote:

n = orig_str.rindex(sub_str)

Thanks. Obviously I have a reading deficiency.

···

--
Posted via http://www.ruby-forum.com/\.