How can I find and replace tab or space characters?
34 次查看(过去 30 天)
显示 更早的评论
I have a string, and I would like to find and replace the tabs and spaces with other characters. However, the STRFIND or STRREP functions don't seem to work.
采纳的回答
MathWorks Support Team
2012-1-17
The main method to replace tabs and spaces in MATLAB is to use regular expressions. Specifically, the REGEXPREP command is able to find tabs or spaces and replace them with any string. For example, to replace tabs with spaces in a string:
updatedString = regexprep(originalString, '\t', ' ');
1 个评论
Bradley Stiritz
2014-5-9
编辑:Bradley Stiritz
2014-5-9
Hi, I'm not sure your proposed method works on non-printing ASCII tab characters. I also need to programmatically replace ASCII tab characters (not visible '\t' sequences).
Do you know please how I can accomplish this? Any help appreciated. Thanks for your consideration.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Characters and Strings 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!