How to separate a portion of filename from a file
10 ビュー (過去 30 日間)
古いコメントを表示
How to separate a portion of filename from a file like I have the file 'scrubbed.MOD_D3_AOD_550.20020112.nc' I just want to extract the '20020112' part
0 件のコメント
採用された回答
その他の回答 (3 件)
Stephen23
2019 年 9 月 8 日
Simpler:
>> str = 'scrubbed.MOD_D3_AOD_550.20020112.nc';
>> out = regexp(str,'\d{8}','match','once')
out = 20020112
2 件のコメント
Adam Danz
2019 年 9 月 8 日
It is simpler and assumes that the string of interest will always have 8 digits and that will be the only sub-string with 8 digits.
Image Analyst
2019 年 9 月 8 日
Try strsplit():
parts = strsplit('scrubbed.MOD_D3_AOD_550.20020112.nc', '.') % Separate in between dots.
yourNumber = parts{end-1} % Take the next to the last one.
2 件のコメント
madhan ravi
2019 年 9 月 8 日
regexp('scrubbed.MOD_D3_AOD_550.20020112.nc',...
'\d*(?=\.nc)','match','once')
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で String Parsing についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!