how to remove certain characters from a string in a file

4 Ansichten (letzte 30 Tage)
Sharen H
Sharen H am 20 Dez. 2012
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 .

Akzeptierte Antwort

Kye Taylor
Kye Taylor am 20 Dez. 2012
Bearbeitet: Kye Taylor am 20 Dez. 2012
Similar to @Srinivas, you could try
str = '32/4/5';
str = regexprep(str,'/.*','');

Weitere Antworten (1)

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

Kategorien

Mehr zu Characters and Strings finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by