How to compact a string?
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
pamela sulis
il 11 Nov 2015
Commentato: pamela sulis
il 11 Nov 2015
Hi! I have a sting 'aaaaaaabccccbbbdcccccaaaa' and I want to trasform it in 'abcbdca': I want to have only one of the consecutive equal value. Can you give me some suggests? Thanks
0 Commenti
Risposta accettata
Walter Roberson
il 11 Nov 2015
Modificato: Walter Roberson
il 11 Nov 2015
s = 'aaaaaaabccccbbbdcccccaaaa'
new_s = regexprep(s, '(.)(\1)+', '$1');
3 Commenti
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Characters and Strings in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!