How to remove a some part of a string from a string?

107 visualizaciones (últimos 30 días)
vijay chandra
vijay chandra el 14 de Sept. de 2017
Comentada: Jan el 15 de Sept. de 2017
Pdus_ENGINE_PKG_ENGINE_ECU_Stat_PT_SENSOR_Container
i want to remove '' engine_pkg_engine_ ''

Respuesta aceptada

Stephen23
Stephen23 el 14 de Sept. de 2017
>> 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

Más respuestas (1)

Akira Agata
Akira Agata el 14 de Sept. de 2017
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 comentarios
vijay chandra
vijay chandra el 15 de Sept. de 2017
thank u Akira. but Erase is not working. it is showing erase is a undefined function or variable in R2016a.
Jan
Jan el 15 de Sept. de 2017
@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.

Iniciar sesión para comentar.

Categorías

Más información sobre Software Development Tools en Help Center y File Exchange.

Etiquetas

Aún no se han introducido etiquetas.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by