Play Games

Search This Blog

Thursday, June 23, 2016

Regular expression to remove consecutive alphabets in apex

Examples :If input is "aabbbbcccdddd" output should be "abcd".
Piece Of Code: 
String str ='aaaabbbbcde';
string resultedString = (str).replaceAll('(.)\\1+', '$1');

System.debug('resultedStringresultedString'+resultedString);


Output :

No comments:

Post a Comment