Replace specific elements in strings
6 次查看(过去 30 天)
显示 更早的评论
I have a quaestion. Which command should I use in order to replace () with -.
for example I have strigs in an array like :
America (New York)
America (Manhattan)
Italy (Rome)
And I would like my output strings to be:
America - New York
America - Manhattan
Italy - Rome
Which command shouls I use? I tried strrep but no use.
Could you please help me?
1 个评论
chrisw23
2023-3-6
repStr = string("America (New York)").replace(" ("," - ").replace(")","")
one of many options
另请参阅
类别
在 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!