How to compact a string?
    2 visualizaciones (últimos 30 días)
  
       Mostrar comentarios más antiguos
    
    pamela sulis
 el 11 de Nov. de 2015
  
    
    
    
    
    Comentada: pamela sulis
 el 11 de Nov. de 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 comentarios
Respuesta aceptada
  Walter Roberson
      
      
 el 11 de Nov. de 2015
        
      Editada: Walter Roberson
      
      
 el 11 de Nov. de 2015
  
      s = 'aaaaaaabccccbbbdcccccaaaa'
new_s = regexprep(s, '(.)(\1)+', '$1');
3 comentarios
Más respuestas (0)
Ver también
Categorías
				Más información sobre Characters and Strings en Help Center y File Exchange.
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!


