From: Brian Candler Date: 2009-11-16T19:14:57+09:00 Subject: Re: replace a very long string with gsub get regexp error Ahmad Azizan wrote: > lala = "Replaced string" > > input = input.gsub(data, lala) > > Is there any other method for that string replacement like in this case > beside using gsub? Here's one option: input = "aaaabbbaaaabbbaaaaabbbaaaabbbaaaa" data = "bb" lala = "zz" pos = 0 while pos = input.index(data, pos) input[pos, data.size] = lala pos += lala.size end -- Posted via http://www.ruby-forum.com/.