The documentation on Whitespace and Delimiter together with space in Formatspec is difficult to interpret (IMO). However, specifying Delimiter overtakes the default value, i.e whitepace. In this example space is needed as a delimiter.
Documentation says:
textscan interprets repeated delimiter characters as separate delimiters,
and returns an empty value to the output cell.
However, in my example below "one or more" spaces are obviously interpreted as one delimiter. That's probably because space is included in the values of both Whitespace and Delimiter. The documentation says little (read nothing) about the effect of different values of Whitespace. (And I don't know C.)
Try this example
str = 'Study Date: 8/30/2013 10:07:30 PM';
cac = textscan( str,'%*s%*s%d%d%d%d%d%d%*s', 'Delimiter',{':','/',' '} );
cac
it returns
cac =
[8] [30] [2013] [10] [7] [30]
 
In response to comment
- I replaced the space in the filename by underscore. Spaces in filenames has caused too many "Cannot open file" over the years.
- There is a tab after "Date:". This file has two columns, name and value, separated by tab.
fid = fopen( 'study_date.txt' );
cac = textscan( fid, '%*s%*s%d%d%d%d%d%d%*s' ...
, 'Delimiter',{':','/',' ','\t'} );
fclose( fid );
cac
returns
cac =
[0] [8] [30] [2013] [10] [7]
ERROR I'll be back
Of course!   ...Date:\t has two delimiters in a row. This is too tricky to my taste.
fid = fopen( 'study_date.txt' );
cac = textscan( fid,'%*s%*s%d%d%d%d%d%d%*s' ...
, 'Delimiter', {':','/',' ','\t'} ...
, 'MultipleDelimsAsOne', true );
fclose( fid );
cac
returns
cac =
[8] [30] [2013] [10] [7] [30]
Conclusion
I have ended up in an overly complicated solution to the literal question. The reason, I think, is that I was concentrating on effects of various values Whitespace and Delimiter and made stepwise fixes.
DONE
 
In response to the comment by Star Strider
IMO: this is a much better way to read the file
fid = fopen( 'study_date.txt' );
cac = textscan( fid,'%s%s', 'Delimiter',{'\t'} );
fclose( fid );
vec = datevec( cac{2}, 'mm/dd/yyyy HH:MM:SS PM' )
returns
vec =
2013 8 30 22 7 30
>>
 
In R2014b textscan( ... 'formatSpec' ... ) has a new feature
convert to a datetime value. fmt describes the format of the input
string. The fmt input is a string of letter identifiers that is a
valid value for the Format property of a datetime.
Best Answer