How to remove additional comma from string?
16 次查看(过去 30 天)
显示 更早的评论
tdat = ["t1,t2,t3", "d2,d3,d4,"]'
How can I remove the extra comma delimiter from string above so result is
tdat = ["t1,t2,t3", "d2,d3,d4"]'
Thanks
1 个评论
Rik
2022-8-25
What have you tried? There are general purpose functions that can do this, as well as string specific functions.
采纳的回答
更多回答(1 个)
Image Analyst
2022-8-25
tdat = ["t1,t2,t3", "d2,d3,d4,"]'
for k = 1 : numel(tdat)
if endsWith(tdat(k), ',')
strLength = length(char(tdat(k)));
tdat(k) = extractBefore(tdat(k), strLength)
end
end
tdat
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!