using regexp for strings with space delimited inside text file
3 views (last 30 days)
I have a text file whose inside as follows;
Time of Applicability(s): 405504.0000
Orbital Inclination(rad): 0.9652538155
Rate of Right Ascen(r/s): -0.7828897534E-008
SQRT(A) (m 1/2): 5153.587402
Right Ascen at Week(rad): 0.2494223175E+001
Argument of Perigee(rad): 0.529637577
Mean Anom(rad): 0.1359485230E+001
I can extract particular string without space inside text as follows (from Azzi Abdelmalek answer);
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?
per isakson on 27 Aug 2016
Edited: per isakson on 27 Aug 2016
It seems that : can be used delimiter between "label" and value.
I would read this file with
fid = fopen('data.txt');
cac = textscan( fid, '%s%f', 'Delimiter',':', 'Whitespace','' );
Inspect the result
'Time of Applicability(s)'
Your code will work if you replace
"work consistently with space delimited strings"   space shouldn't be a problem. However, the parentheses, (), requires an escape character, \( and \), respectively.