Replace invalid characters from HTML file with valid ones and save the file.
조회 수: 1 (최근 30일)
이전 댓글 표시
Hi all,
I am currently working on a script for editing the html file. (MATLAB 2013b)
The HTML file has some invalid characters like m³. And I want replace these characters e.g. m³ to m3.
I am able to read the html file as a cell of 4405x1 cell. Here, I am not able to use strrep command. Following is the code:
fid = fopen('C0TH_Doc_main.html','r');
MyText = textscan(fid,'%s','delimiter','\n');
strrep(MyText, 'm³', 'm3');
% rewrite the file
fid = fopen('C0TH_Doc_main.html','wt');
fprintf(fid,'%s\n',MyText);
fclose(fid);
Following is error screenshot
![2020-01-30 11_06_38-MATLAB R2013b.jpg](https://www.mathworks.com/matlabcentral/answers/uploaded_files/269077/2020-01-30%2011_06_38-MATLAB%20R2013b.jpeg)
Once all the characters are replaced, I want to preferably save it to the same HTML file or atleast wirte it into a new txt file.
Please provide any hints or other ways to complete this task.
Thank you in Advance
댓글 수: 0
채택된 답변
Walter Roberson
2020년 1월 30일
MyText = strrep(MyText{1}, 'm³', 'm3');
댓글 수: 2
Walter Roberson
2020년 1월 30일
By the way you could consider using regexprep to do all the replacements in one call.
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Get Started with MATLAB에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!