Hi
I would like to make a routine that can replace multiple lines with other multiple lines in a ascii file. This could for example be to replace 7 lines with 4 lines. I can not do it one line at the time because the single lines of the 7 lines are present other places in the file than in the 7 lines.
For single line replacement I have used
fin = fopen('in.txt','r');fout = fopen('out.txt', 'w+');while ~feof(fin) s = fgetl(fin); s = strrep(s, 'old string', 'newstring'); fprintf(fout,'%s\n',s);endfclose(fin);fclose(fout);
But I can't figure out an easy way to convert this to handle multiple lines replacement.
Do you have any ideas?
Thanks in advance.
Regards Brian.
Best Answer