From: Mat Schaffer Date: 2006-07-06T04:46:58+09:00 Subject: Re: Find Position of text On Jul 5, 2006, at 3:39 PM, Joel VanderWerf wrote: > j3n7il jones wrote: >> Is thier also a way to go to the next occurence? >> Like >> input = : cat : bat : mat : >> param = getparam(input,':', 3) >> then param would equal "mat" >> See what I Mean? > > Lots of ways to do this. One way: > > irb(main):016:0> input > => ": cat : bat : mat :" > irb(main):017:0> input.scan(/: ([^:]*) /)[2] > => ["mat"] > > The hard part is getting the regex right. Regex are fun and all, but why not just: input = ": cat : bat : mat :" input.split(":")[4].strip -Mat