matlab安全替换一个或多个文件中的一个或多个字符串

收录时间:2019-11-07
资源分类:Matlab 工具:MATLAB 7.14 (R2012a)

安全替换一个或多个文件中的一个或多个字符串

 

strrepfile

strrepfile(filename,S1,S2) replaces all occurrences of the string S1 in the file filename with the string S2. S1, S2 may also be cell arrays of strings of the same size, in which case the replacement is performed for each pair by performing a strrep using corresponding elements of the inputs. Alternatively S2 may be a string string with and S1 a cell array, in this case the single string S2 will replace all the strings in S1

 

-----

 

strrepfile replaces the string by creating a temporary copy of the file in which the replace is to be performed, replacing it in this file, and copying the file back to the original location for safety. Submission #42877 has the advantage of allowing regex replace, but is not as safe as this version. strrepfile could probably be modified to use regexprep quite easily.

 

---

 

Note strrepfile requires 'samesize.m' my file exchange contribution here: http://www.mathworks.com/matlabcentral/fileexchange/36636-samesize

文件下载列表
strrepfile.zip (2.9KB)  
附件内容(只显示2中的1个)
strrepfile.m  
更多

目前尚无评论

用户反馈   关于我们
Copyright (©) ZHIHUISHI.COM 2013 All Rights Reserved.
京ICP备14040384号