title: Checking the format of a string in Matlab
body: <p>So I'm reading multiple text files in Matlab that have, in their first columns, a column of "times". These times are either in the format 'MM:SS.milliseconds' (sorry if that's not the proper way to express it) where for example the string '29:59.9' would be (29*60)+(59)+(.9) = 1799.9 seconds, or in the format of straight seconds.milliseconds, where '29.9' would mean 29.9 seconds. The format is the same for a single file, but varies across different files. Since I would like the times to be in the second format, I would like to check if the format of the strings match the first format. If it doesn't match, then convert it, otherwise, continue. The code below is my code to convert, so my question is how do I approach checking the format of the string? In otherwords, I need some condition for an if statement to check if the format is wrong.</p>
  
  <pre><code> %% Modify the textdata to convert time to seconds
      timearray = textdata(2:end, 1);
      if (timearray(1, 1) %{has format 'MM.SS.millisecond}%)
          datev = datevec(timearray);
          newtime = (datev(:, 5)*60) + (datev(:, 6));
  
      elseif(timearray(1, 1) %{has format 'SS.millisecond}%)
          newtime = timearray; 
  </code></pre>