How to retrieve a word from a filename
조회 수: 1 (최근 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에서 Migrate GUIDE Apps에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!