From: Li Chen Date: 2007-07-31T22:25:35+09:00 Subject: How to substitute a string with different size Hi all, I deal with a mixture of text and binary file. I want to search a pattern in the string and replace it with a new pattern, then write to a new file. I use the following script(only part of the script) str.gsub!(/old_pattern/,"new_pattern") file.seek(-str.length,IO::SEEK_CUR) file.print str It works fine if the both old_pattern and new_pattern are the same size. But it will produce unpreditable result if the sizes are different. I wonder if any one out there knows how to explain it and provide a Ruby way solution. Thanks, Li -- Posted via http://www.ruby-forum.com/.