Does anyone know how to find the index of a substring or character in a string?
Thanks!
Find index of substring or character in string.
Moderator: DosItHelp
Hi lstewart,
try this
the :strLen function is from the DosTips-Library
hope it helps
Jan Erik
try this
Code: Select all
setlocal
set str=abcdefghijklmnopqrstuvxyz
call :indexOf result "%str%" "e"
echo %result%
goto :eof
::::::::::::::::::::::::::::::::::::::::::::::::::::
:indexOf <resultVar> <str> <find>
SETLOCAL
set "str=%~2"
call set "part=%%str:%~3=&rem.%%"
set partB=%part%
call :strLen partB len
( ENDLOCAL
set %~1=%len%
EXIT /b
)
the :strLen function is from the DosTips-Library
hope it helps
Jan Erik