So I initially came up with this:
Code: Select all
@echo off
setlocal enabledelayedexpansion
set var=SssstoOoormUUUu
echo input string is: %var%
FOR /L %%G in (0,1,11) do call :parse %%G
echo final string is: %var%
Pause
goto :eof
:parse
set N1=%~1
set /a N2=%~1+1
set four=!var:~%N1%,4!
set three=!var:~%N1%,3!
IF /I "!var:~%N1%,3!"=="!var:~%N2%,3!" set var=!var:%four%=%three%
Which outputs this:
Code: Select all
input string is: SssstoOoormUUUu
final string is: SsstoOormUUU
But then I thought to myself. This could really be a pretty cool function if it was more flexible.
Would need to be able to pass to it how many repeating characters you really wanted within your string and could it be made flexible enough to not have to know what the initial string length was and I assume we would have the usual issues if the string had special characters in it.
Not sure if this has been done already or not. Couldn't find anything in the library but maybe I missed it.