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
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!