How to remove a some part of a string from a string?
99 次查看(过去 30 天)
显示 更早的评论
Pdus_ENGINE_PKG_ENGINE_ECU_Stat_PT_SENSOR_Container
i want to remove '' engine_pkg_engine_ ''
0 个评论
采纳的回答
Stephen23
2017-9-14
>> str = 'Pdus_ENGINE_PKG_ENGINE_ECU_Stat_PT_SENSOR_Container';
>> regexprep(str,'engine_pkg_engine_','','ignorecase')
ans =
Pdus_ECU_Stat_PT_SENSOR_Container
or
>> strrep(str,'ENGINE_PKG_ENGINE_','')
ans =
Pdus_ECU_Stat_PT_SENSOR_Container
更多回答(1 个)
Akira Agata
2017-9-14
If your MATLAB is R2016b or later version, you can use erase function, like:
>> str = 'Pdus_ENGINE_PKG_ENGINE_ECU_Stat_PT_SENSOR_Container';
>> erase(str, 'ENGINE_PKG_ENGINE_')
ans =
Pdus_ECU_Stat_PT_SENSOR_Container
2 个评论
Jan
2017-9-15
@GADIDHIMI SAI KUMAR BABU: Did you see Akira's hint: "If your MATLAB is R2016b or later version ..."? erase works with the modern string class only.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Software Development Tools 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!