finding carriage returns (i.e. \n) in a text file
Ältere Kommentare anzeigen
Hi all, I have a text file with carriage returns in it, and am trying to test if an index is a carriage return but have been unsuccessful. For simplicity, lets say that the text file only uses \r as a carriage return. I understand that isstrprop(text(index),'wspace') can identify if it is a space OR a carriage return, but I want to check only to see if it is a carriage return.
Any advice? Let me know if I can be any clearer here.
Thank you so much in advance, William
Akzeptierte Antwort
Weitere Antworten (3)
Walter Roberson
am 19 Jan. 2016
YourString == sprintf('\r')
or
YourString == char(13)
Note: char(13) is \r the carriage return. Your description uses the word carriage return but uses \n which is newline, char(10) . You need to decide which you are looking for. If you are looking for either, then
ismember(YourString, char([10 13]))
Will Kinsman
am 19 Jan. 2016
0 Stimmen
1 Kommentar
Star Strider
am 19 Jan. 2016
My pleasure!
They’re fun for me — I probably learn as much as I contribute.
Lamin Moore
am 31 Mär. 2019
0 Stimmen
function res = capitalizeVowels(myWord)
Kategorien
Mehr zu Characters and Strings finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!