How to remove additional comma from string?
8 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Pete sherer
am 25 Aug. 2022
Verschoben: Rik
am 26 Aug. 2022
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 Kommentar
Rik
am 25 Aug. 2022
What have you tried? There are general purpose functions that can do this, as well as string specific functions.
Akzeptierte Antwort
Stephen23
am 26 Aug. 2022
tdat = ["t1,t2,t3"; "d2,d3,d4,"]
tdat = regexprep(tdat,',+$','')
1 Kommentar
Weitere Antworten (1)
Image Analyst
am 25 Aug. 2022
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 Kommentare
Siehe auch
Kategorien
Mehr zu Characters and Strings finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!