Asp Forum
Home
|
Login
|
Register
|
Search
Forums
>
comp.lang.ruby
String search backwards?
Toby DiPasquale
1/24/2006 8:06:00 PM
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-...
.
1 Answer
matthew.moss.coder
1/24/2006 8:22:00 PM
0
n = orig_str.rindex(sub_str)
Servizio di avviso nuovi messaggi
Ricevi direttamente nella tua mail i nuovi messaggi per
String search backwards?
Inserendo la tua e-mail nella casella sotto, riceverai un avviso tramite posta elettronica ogni volta che il motore di ricerca troverà un nuovo messaggio per te
Il servizio è completamente GRATUITO!
x
Login to ForumsZone
Login with Google
Login with E-Mail & Password