I tried the below code to search the string pattern "]]>*/-->" and replace it with "*/-->" using gsub function.
but instead of replacing whole string. it replaces character wise..
File.open('reporttestphp2.xml', 'r+') do |f1|
while line = f1.gets
f1.puts line.gsub("]]>*/-->","*/-->")
end
end
How can I replace the whole string pattern in Ruby?
The gsub works fine. You just need to read the file in a different way:
I hope, that helps.