I have a text file whose inside as follows;
ID: 01Eccentricity: 0.5846023560E-002Time of Applicability(s): 405504.0000Orbital Inclination(rad): 0.9652538155Rate of Right Ascen(r/s): -0.7828897534E-008SQRT(A) (m 1/2): 5153.587402Right Ascen at Week(rad): 0.2494223175E+001Argument of Perigee(rad): 0.529637577Mean Anom(rad): 0.1359485230E+001
I can extract particular string without space inside text as follows (from Azzi Abdelmalek answer);
fid=fopen('data.txt')s=fgetl(fid)out={}while ischar(s) out{end+1}=regexp(s,'(?<=(ID:))\s+\S+','match','once') s=fgetl(fid);endfclose(fid)idx=~cellfun(@isempty,out);out=strtrim(reshape(out(idx),1,[]))'
But when it comes to other strings with space delimited (Time of Applicability(s): and the others) above codes don't work. How can I modify above codes to work consistently with space delimited strings?
Best Answer