필터 지우기
필터 지우기

Info

이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.

Count how many ‘a’ are in str and eliminate those ‘a’

조회 수: 1 (최근 30일)
nty huy
nty huy 2019년 10월 15일
마감: MATLAB Answer Bot 2021년 8월 20일
so for ex in a str= i have an apple
and we want to see how many a and remove them we would use
str1= 'a'
ind = strfind(str, str1)
str(ind) = ''
how would we use a loop for this?
  댓글 수: 1
Rik
Rik 2019년 10월 15일
Backup of question in case of edit-delete:
so for ex in a str= i have an apple
and we want to see how many a and remove them we would use
str1= 'a'
ind = strfind(str, str1)
str(ind) = ''
how would we use a loop for this?

답변 (1개)

Daniel M
Daniel M 2019년 10월 15일
s = 'I have an apple';
[a,b] = regexp(s,'a','split');
numA = length(b);
sentenceWithoutA = strjoin(a);
  댓글 수: 5
nty huy
nty huy 2019년 10월 15일
ok reported :)
Rik
Rik 2019년 10월 15일
You would probably get a chuckle out of your teacher if you handed in that loop. Also, flagging is not doing what you think. It does attract the attention of site administrators, but it is more likely flags will be dealt with by high reputation members, so exactly the people whose comments you are flagging.

이 질문은 마감되었습니다.

태그

Community Treasure Hunt

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

Start Hunting!

Translated by