@echo off&set FileName=%~n0&shift :: ============================================= :: AutoHelp PlugLab Concept: 2006 by Reatogo :: ============================================= :: Help Info: :: ======================= set Routine_Type=1 :: 1=Getting Data 2=Prompts 3=Getting Files 4=Creating Files 5=General set Routine_Vers=1 set Routine_Date=2007-02-15 set RoutineName=String set RoutineAuthor=Siegfried set Using_work_from= set Example_call_1=special if "%~1" == "GetHelp" goto :EOF if not "%~3" == "s" echo.&echo %* :: ============================================= :String :: ============================================= set result= set MyString=%~1 FOR /F "tokens=1-2* delims==" %%a IN ("%~2") DO ( set TrimRoutine=%%a FOR /F "tokens=1-2* delims=," %%i IN ("%%b") DO ( set frontN=%%i set tailN=%%j ) call :%%a ) ::echo result is "%result%" :: ======================== goto :EOF :: ======================== :token :: ======================== if "%tailN%" == "blank" set tailN= if "%tailN%" == "comma" set tailN=, if "%tailN%" == "" set tailN=^= set tcn=1 :tokloop1 FOR /F "tokens=%tcn%* delims=%tailN%" %%a IN ("%MyString%") DO ( if "%frontN%" == "%tcn%" ( set result=%%a goto tokFound ) if "%%a"=="" goto tokFound set /a tcn +=1 goto tokloop1 ) :tokFound goto :EOF :: ======================== :trim :: ======================== SETLOCAL ENABLEDELAYEDEXPANSION if "%tailN%" == "0" ( echo set result=!MyString:~%frontN%!>> "%temp%\TempLab.cmd" ) else ( echo set result=!MyString:~%frontN%,-%tailN%!>> "%temp%\TempLab.cmd" ) ENDLOCAL if exist "%temp%\TempLab.cmd" ( call "%temp%\TempLab.cmd" del "%temp%\TempLab.cmd" ) goto :EOF :: ======================== :pick :: ======================== set tempfrontN=%frontN% SETLOCAL ENABLEDELAYEDEXPANSION set /a frontN-=1 if "%tempfrontN%" == "0" set frontN=x set last= if not "%tailN%" == "0" set last=!MyString:~-%tailN%,1! set first= if not "!frontN!" == "x" set first=!MyString:~+%frontN%,1! echo set result=!first!!last!>> "%temp%\TempLab.cmd" ENDLOCAL if exist "%temp%\TempLab.cmd" ( call "%temp%\TempLab.cmd" del "%temp%\TempLab.cmd" ) set tempfrontN= goto :EOF :: ======================== :rightget :: ======================== if "%tailN%" == "" set tailN=%frontN% SETLOCAL ENABLEDELAYEDEXPANSION if not "%tailN%" == "0" if not "%frontN%" == "0" ( echo set result=!MyString:~-%frontN%,%tailN%!>> "%temp%\TempLab.cmd" ) ENDLOCAL if exist "%temp%\TempLab.cmd" ( call "%temp%\TempLab.cmd" del "%temp%\TempLab.cmd" ) goto :EOF :: ======================== :leftget :: ======================== set tempfrontN=%frontN% if "%tailN%" == "" set tailN=%tempfrontN%&set frontN=1 SETLOCAL ENABLEDELAYEDEXPANSION set /a frontN-=1 if not "%tempfrontN%" == "0" echo set result=!MyString:~+%frontN%,%tailN%!>> "%temp%\TempLab.cmd" ENDLOCAL if exist "%temp%\TempLab.cmd" ( call "%temp%\TempLab.cmd" del "%temp%\TempLab.cmd" ) set tempfrontN= goto :EOF :: ======================== :replace :remove :: ======================== SETLOCAL ENABLEDELAYEDEXPANSION echo set result=!MyString:%frontN%=%tailN%!>> "%temp%\TempLab.cmd" ENDLOCAL if exist "%temp%\TempLab.cmd" ( call "%temp%\TempLab.cmd" del "%temp%\TempLab.cmd" ) goto :EOF :: ======================== :: =============================================