Find count of repeated letters

1 vue (au cours des 30 derniers jours)
Jothi
Jothi le 30 Sep 2013
Commenté : Jothi le 7 Oct 2013
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

Réponse acceptée

Azzi Abdelmalek
Azzi Abdelmalek le 30 Sep 2013
a='I want THAAAAAT APPPPPLE ):):):'
s=regexp(a,'\s+','split')
out=s(~cellfun(@(x) numel(unique(x))==numel(x),s))
  3 commentaires
Azzi Abdelmalek
Azzi Abdelmalek le 1 Oct 2013
In totally, ll are not repeated letter?
Jothi
Jothi le 7 Oct 2013
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.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Characters and Strings dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by