MATLAB: Data extraction with undefined file length

sscanf

I have a large data file and I want to extract specific data from this file. However, I want to program the system in such a way that I can input the same sort of data file into the program and it will still give the same outcome. So for example, there is a string called
tline =' : W A V E P E R I O D = 3.6000E+01 : ';
within the data file. This string occurs on different locations for different data files. What I want to extract from the data file is 3.6000E+01. What I have got so far (but does not work) is:
A = sscanf(tline,' : W A V E P E R I O D = %1.4e : ');
Regards, Mark.

Best Answer

Try this
str = fileread( 'lorem.txt' );
cac = regexp( str, '(?<=W A V E P E R I O D =)\s*[\d\.\E\+\-]+', 'match','once' )
it outputs
cac =
3.6000E+01
where lorem.txt is attached