- Jul
- 532
- 10
This one is killing me because TCC doesn't have regex substitution that I know about, and I'd rather not rely on sed.
I just want to be able to do:
I'd also like this function to be created inside of a bat file, as it's going to be part of my set-colors.bat that defines all my ansi characters.
Just having trouble making it myself because of a lack of experience with functions in general.
Adding to the complication is I'm doing this within a BAT file, so it has to be a oneliner? What I've currently got, which doesn't return the value correctly (how do you return values?), but which seems to maybe work internally, is:
I just need to get my example working. I am 100% positive that "return %stripped%" at the end is nonsense that doesn't do anything
I just want to be able to do:
Code:
set CLEAN_TITLE=%@STRIP_ANSI[%title_with_ansi]
Just having trouble making it myself because of a lack of experience with functions in general.
Adding to the complication is I'm doing this within a BAT file, so it has to be a oneliner? What I've currently got, which doesn't return the value correctly (how do you return values?), but which seems to maybe work internally, is:
Code:
function strip_ansi_fail=`set string=%1$ %+ unset /q stripped %+ :loop %+ for /f "tokens=1,* delims=" %%a in ("%string%") do ( set "stripped=!stripped!%%a" %+ set "string=%%b" ) %+ if not "%string%"=="" goto :loop %+ return %stripped%"`
I just need to get my example working. I am 100% positive that "return %stripped%" at the end is nonsense that doesn't do anything