How to remove a part of string from a string. not manually.
Show older comments
Pdus_ENGINE_PKG_ENGINE_CPC_ENGINE_COM01_Container_ST3
I need Pdus only. I want to remove remaining part which is inside braces from the above string.i dont want to remove it manually by considering the remaining part.i need it in some other way.
(_ENGINE_PKG_ENGINE_CPC_ENGINE_COM01_Container_ST3).
Answers (1)
Image Analyst
on 10 Oct 2017
Here's one way:
str = str(1:4); % Extract only the first 4 characters.
If that doesn't do it, then say why not.
By the way, the "above string" doesn't have braces in it.
2 Comments
vijay chandra
on 11 Oct 2017
Image Analyst
on 11 Oct 2017
You can get rid of braces first like this
str = strrep(str, '{', '');
str = strrep(str, '}', '');
str = str(1:4); % Extract only the first 4 characters.
Categories
Find more on Characters and Strings in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!