Skip to content

Commit

Permalink
Update endsWith.bat
Browse files Browse the repository at this point in the history
  • Loading branch information
npocmaka committed Dec 12, 2017
1 parent 56bda6b commit 55078e3
Showing 1 changed file with 12 additions and 14 deletions.
26 changes: 12 additions & 14 deletions stringutils/endsWith.bat
@@ -1,5 +1,5 @@
:endsWith [%1 - string to be checked;%2 - string for checking ]
::http://ss64.org/viewtopic.php?id=1687

@echo off
rem :: sets errorlevel to 1 if %1 ends with %2 else sets errorlevel to 0

Expand All @@ -14,19 +14,17 @@ set LF=^
rem ** Two empty lines are required
rem echo off
for %%L in ("!LF!") DO (
for /f "delims=" %%R in ("!checker!") do (
rem set "var=!string:%%~R%%~R=%%~L!"
set "var=!string:%%~R=%%L#!"
)
for /f "delims=" %%R in ("!checker!") do (
rem set "var=!string:%%~R%%~R=%%~L!"
set "var=!string:%%~R=%%L#!"
)
)
for /f "delims=" %%P in (""!var!"") DO (
set "temp=%%~P"
set "temp=%%~P"
)

if "%temp%" EQU "#" (
endlocal & exit /b 1
) else (
endlocal & exist /b 0
)
if "%temp%" EQU "#" goto :yes
goto :no
:yes
endlocal & verify set_error 2>nul
goto :eof
:no
endlocal & ( echo | shift )
goto :eof

0 comments on commit 55078e3

Please sign in to comment.