How can I find and replace tab or space characters?
34 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
MathWorks Support Team
am 17 Jan. 2012
Bearbeitet: Bradley Stiritz
am 9 Mai 2014
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.
Akzeptierte Antwort
MathWorks Support Team
am 17 Jan. 2012
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 Kommentar
Bradley Stiritz
am 9 Mai 2014
Bearbeitet: Bradley Stiritz
am 9 Mai 2014
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.
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Characters and Strings finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!