How do I detect a "tab" character in a line of text read by fgetl?
25 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Clay Fulcher
am 21 Mai 2020
Beantwortet: Clay Fulcher
am 22 Mai 2020
I am using fgetl to read lines in a text file. Is there a way to detect whether one of the whitespace characters is a "tab" ?
Thanks in advance for your help.
0 Kommentare
Akzeptierte Antwort
dpb
am 21 Mai 2020
l=fgetl(fid);
istab=(l==9); % the fast way...
%
istab=strfind(l,char(9)); % the char() string string functions way
Weitere Antworten (2)
Walter Roberson
am 21 Mai 2020
S = sprintf('abc\tdef'); %text with a tab in it
S == 9 %fast, simple, and tab character unlikely to change any year soon
strfind(S, sprintf('\t')) %just in case tab someday changes to a multi-character sequence
%unicode defines three additional tab-related functions
ismember(S, [0x09 0x0b 0x88 0x89 0x8a]) %HT VT CTS CTJ LTS
%unicode defines several tab symbols
ismemember(S, [0x09 0x0b 0x88 0x89 0x8a 0x2409 0x240b 0x21b9 0x21c6 0x21E4 0x21E5]) %HT VT CTS CTJ LTS various tab symbols
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!