@yuhunglin Ah, ruby has a buil-in .rindex string method http://apidock.com/ruby/String/rindex  Works nicely!