Description
Remove consecutive repeated characters of a string,
but we have no idea which character will repeat.
|
| Raw Input
| ABcccDeeFggggHIJkkk
mnoXXXXpqrYYstZZZZuvw
|
|
| Desired Output
| ABDFHIJ
mnopqrstuvw
|
|
Script and Comments
Script1 [ 1] s/(.)\1\1*//g
|
Script2 [ 1] s/^.*/\n&\n/
[ 2] t loop
[ 3] :loop
[ 4] /\n\n/{
[ 5] P
[ 6] d
[ 7] }
[ 8] s/\n(.)(\1.*\n)/\n\2\1/
[ 9] t loop
[10] s/\n(.)/\1\n/
[11] s/(.)(\n.*\n)\1/\2/
[12] s/\n[^\n]*$//
[13] t loop
| |