I want to create a function that shortcut domain name pattern.
The only "law" of the function is that if there is a letter that repeats itself more than 5 times in a row such as LLLLLLL or NNNNNN or even mixed letter LLLLLLLNNNNNN we will get a shortcut in all cases ie 6 times of L sequence will change to L6 and so on in other cases.
Now I want to shorten the domin for example incase the string is 5 letters or numbers in sequence together, I want to create a shortcut.
- For example:
- LLLLLLLL -> L8
- NNLLLLLLLN -> NNL7N
- LLLLLLLNNNNNN -> L6N6.
I thought at the first to use "str_replace" function but, the problem is there are infinite examples of shortening.