in reply to Compressing a text file using count of continous characters
it search for a non-number, then search if it's repeated 1 or more times, then replace it by the count of them followed by the the repeated chars/((\D)\2+)/length($1).$2/ge;
PS: could be usefull to limit the number of repeated matches, and include the numbers. but in this case numbers must always have a counter:
this one will compare 2 or more char, or 1 or more if digit and match no more then a sequence of 9.s/((\D)\2{1,8}|(\d)\3{0,8})/length($1).$2.$3/ge;
s/(\d)(.)/$2x$1/ge;
Oha
|
|---|