how to delete the dot in a string
11 次查看(过去 30 天)
显示 更早的评论
like bbc.ed.123.f.txt how to change it to bbced123f.txt
0 个评论
采纳的回答
Andrei Bobrov
2014-1-21
编辑:Andrei Bobrov
2014-1-21
a = 'bbc.ed.123.f.txt';
regexprep(a,{'\.','txt'},{'','.txt'})
or
[strrep(a(1:end-4),'.',''),'.txt']
更多回答(1 个)
ES
2014-1-21
you have to handle the last dot(before file extension) and the other dots separately.
str='bbc.ed.123.f.txt';
idx=strfind(str,'.');
new_str=[strrep(str(1:idx(end)-1),'.',''),str(idx(end):end)];%idx(end) is the position of the last dot!
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Characters and Strings 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!