How can I find and replace tab or space characters?

37 ビュー (過去 30 日間)
MathWorks Support Team
MathWorks Support Team 2012 年 1 月 17 日
編集済み: Bradley Stiritz 2014 年 5 月 9 日
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
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
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 ExchangeCharacters and Strings についてさらに検索

製品


リリース

R2011b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by