From: Bob Gustafson Date: 2002-04-26T23:34:03+09:00 Subject: Re: Return last match instead of first? >'abcdefabc' =~ 'abc' returns 0 > >How do I get it to return 6? ... finding the second abc? > >Or return 9 in this case: > >'abcdefabcabc' =~ 'abc' > >Chris Morris >chris.morris@snelling.com A cluge, but: a = 'abcdefabc' p = 'abc' i = (a.reverse =~ p.reverse) + a.length - p.length irb(main):014:0> a = 'abcdefabc' "abcdefabc" irb(main):015:0> irb(main):016:0* p = 'abc' "abc" irb(main):017:0> irb(main):018:0* i = (a.reverse =~ p.reverse) + a.length - p.length 6 irb(main):019:0>