MATLAB: Using regular expression to read part of the filename

regular expressiontimestamp

Good afternoon,
I am attempting to use a regular expression feature to read part of the file that is generated by the microscope camera.
The file format is x_yyyymmdd_hhmmSSsss where small s is the milisecond and x is the number of the timelapsed photo.
I am trying to convert (truncate) say 5_20180927_161742655 to 20180927_161742 so that I can use this as a timestamp more easily.
Any help would be appreciated. Thank you.

Best Answer

>> str = '5_20180927_161742655';
>> regexp(str,'(?<=_)\d{8}_\d{6}','match','once')
ans = 20180927_161742
Note that the input str can also be a cell array of char vector, or a string array.