how to remove certain characters from a string in a file

조회 수: 7 (최근 30일)
Sharen H
Sharen H 2012년 12월 20일
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 .

채택된 답변

Kye Taylor
Kye Taylor 2012년 12월 20일
편집: Kye Taylor 2012년 12월 20일
Similar to @Srinivas, you could try
str = '32/4/5';
str = regexprep(str,'/.*','');

추가 답변 (1개)

Srinivas
Srinivas 2012년 12월 20일
one way
mystr = '32/4/5'
loc = strfind(mystr,'/')
mystr(loc(1):end) =[]

카테고리

Help CenterFile Exchange에서 Characters and Strings에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by