How to retrieve a word from a filename
5 ビュー (過去 30 日間)
古いコメントを表示
name:"rgb_watermark_lena.jpg"
I want to retrieve only "lena" word from file
It should be "lena.jpg"
Can any one sort out this problem
0 件のコメント
採用された回答
Jakob Sørensen
2012 年 5 月 6 日
name = 'rgb_watermark_lena.jpg';
name(end-7:end-4)
ans =
lena
You probably get the point :)
0 件のコメント
その他の回答 (1 件)
Neil Caithness
2012 年 5 月 6 日
It rather depends on how general you want it. Here's another example that may help you decide.
filename = 'rgb_watermark_lena.jpg';
[~, name, ext] = fileparts(filename);
nameparts = regexp(name, '_', 'split');
newfilename = fullfile([nameparts{end} ext])
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Denoising and Compression についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!