Find count of repeated letters

조회 수: 1 (최근 30일)
Jothi
Jothi 2013년 9월 30일
댓글: Jothi 2013년 10월 7일
Sir,
How to find the no. of repeated sequence (letters) in the given sentence.
for example, a="I want THAAAAAT APPPPPLE ):):):";
The No. of repeated sequences are: 3
ie.,
1. THAAAAAT
2. APPPPPLE
3. ):):):
thanks

채택된 답변

Azzi Abdelmalek
Azzi Abdelmalek 2013년 9월 30일
a='I want THAAAAAT APPPPPLE ):):):'
s=regexp(a,'\s+','split')
out=s(~cellfun(@(x) numel(unique(x))==numel(x),s))
  댓글 수: 3
Azzi Abdelmalek
Azzi Abdelmalek 2013년 10월 1일
In totally, ll are not repeated letter?
Jothi
Jothi 2013년 10월 7일
But one problem sir,
The input file is ,
a='I want THAAAAAT APPPPPLE ):):): totally unprepared'
In this input we get
out =
'THAAAAAT' 'APPPPPLE' '):):):' 'totally' 'unprepared'
But the required output is,
out =
'THAAAAAT' 'APPPPPLE' '):):):'
how to solve this problem.
thank you sir.

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

추가 답변 (0개)

카테고리

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