필터 지우기
필터 지우기

Removing Part of A String

조회 수: 3 (최근 30일)
Syed Abbas
Syed Abbas 2011년 12월 27일
Hi, I have a string of numbers of in the format '7646 89:89'. I basically want to remove the numbers following the white space e.g I want '7646 89:89' to become '7649'. Thanks

채택된 답변

Fangjun Jiang
Fangjun Jiang 2011년 12월 27일
s='7646 89:89';
d=textscan(s,'%f*');
d=d{1};
  댓글 수: 1
Jan
Jan 2011년 12월 27일
TEXTSCAN is very powerful, and in consequence it is slow.

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Jan
Jan 2011년 12월 27일
Faster than the very powerful TEXTSCAN:
s = '7646 89:89';
d = strtok(s, ' ');
Or simply:
d = strtok(s);
Or:
index = strfind(s, ' ');
d = s(1:index(1));
  댓글 수: 1
Syed Abbas
Syed Abbas 2011년 12월 27일
Thanks a lot!

댓글을 달려면 로그인하십시오.

카테고리

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