MATLAB: How to extract the HH:MM:SS.FFF portion of a julian day time stamp

julian time stampsregexp

I have a 2×1 cell array containing the following data;
Data_Time_Stamps_Cells =
' 086 2020 18:30:19.578'
' 086 2020 18:30:18.569'
I'm attempting to extract the HH:MM:SS.FFF portion of these time stamps using the following:
exp = '([\d:\.]+)';
times = regexp(Data_Time_Stamps_Cells, exp, 'tokens');
The result is a 2 x 1 cell array;
times =
'086' '2020' '18:30:19.578'
'086' '2020' '18:30:18.569'
Why am I getting the entire contents of the Data Time Stamps Cells in 3 individual cells?

Best Answer

times = regexp(Data_Time_Stamps_Cells, '\d{1,2}:\d{2}:\d{2}\.\d{3}', 'match', 'once');
But you might as well do
cellfun(@(D) D(end-11:end), Data_Time_Stamps_Cells, 'uniform', 0)
exp = '([\d:\.]+)';
[\d:\.] means any one character that is a digit or a colon or a period. The + after that pattern means one or more occurances.
In ' 086 ', the 0 matches a digit, the 8 matches a digit, the 6 matches a digit, the space after does not match a digit or colon or period. So '086' would be matched.