How to remove a some part of a string from a string?
39 ビュー (過去 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 で String Parsing についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!