how to remove certain characters from a string in a file

2 visualizaciones (últimos 30 días)
how to remove certain characters from a string based on some condition ie i have a text in a file '32/4/5' i want to retain only 32 and delete rest .my condition is if a '/' is identified then rest characters should be deleted .

Respuesta aceptada

Kye Taylor
Kye Taylor el 20 de Dic. de 2012
Editada: Kye Taylor el 20 de Dic. de 2012
Similar to @Srinivas, you could try
str = '32/4/5';
str = regexprep(str,'/.*','');

Más respuestas (1)

Srinivas
Srinivas el 20 de Dic. de 2012
one way
mystr = '32/4/5'
loc = strfind(mystr,'/')
mystr(loc(1):end) =[]

Categorías

Más información sobre Characters and Strings en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by