How can I detect end of lines in a output string of a dos command?
4 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Andy
el 20 de En. de 2014
Comentada: Andy
el 20 de En. de 2014
I execute e.g.:
>> [status, cmdout] = dos(['tracert www.google.com']);
>> cmdout
When I copy the output of the Matlab command window and paste it into Notepad++, I see a CR and LF at the end of each line. Finding these with strfind does not return what I expect:
>> strfind(cmdout,'\r\f')
ans =
[]
How can I divide the cmdout string into individual lines?
0 comentarios
Respuesta aceptada
Friedrich
el 20 de En. de 2014
Editada: Friedrich
el 20 de En. de 2014
Hi,
try
lines = regexp(cmdout,'\n','split')
Or
lines = textscan(cmdout,'%s','delimiter','\n')
However you will get a few empty lines because of the way the cmdout is generated. Sometimes you have two newline indicators before an actual line. But this should help get started.
Más respuestas (1)
Amit
el 20 de En. de 2014
Editada: Amit
el 20 de En. de 2014
CR and FR are carriage return and line feed. Most of the notepad type application do not show it.
The reason strfind does not find it because its not there. Have you tried pasting it in a different word processor like windows native wordpad or notepad?
0 comentarios
Ver también
Categorías
Más información sobre String Parsing en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!