Data update

This commit is contained in:
Ingy döt Net 2026-04-30 12:34:36 -04:00
parent 4bb20c9b71
commit cbaf4c4b64
12390 changed files with 318560 additions and 27248 deletions

View file

@ -0,0 +1,70 @@
::NOTE #1: This implementation might crash, or might not work properly if
::you put some of the CMD special characters (ex. %,!, etc) inside the strings.
::
::NOTE #2: The comparisons here are case-SENSITIVE.
::NOTE #3: Spaces in strings are considered.
@echo off
setlocal enabledelayedexpansion
::The main things...
set "str1=qwertyuiop"
set "str2=qwerty"
call :str2_lngth
call :matchbegin
set "str1=qweiuoiocghiioyiocxiisfguiioiuygvd"
set "str2=io"
call :str2_lngth
call :matchcontain
set "str1=blablabla"
set "str2=bbla"
call :str2_lngth
call :matchend
echo.
pause
exit /b 0
::/The main things.
::The functions...
:matchbegin
echo.
if "!str1:~0,%length%!"=="!str2!" (
echo "%str1%" begins with "%str2%".
) else (
echo "%str1%" does not begin with "%str2%".
)
goto :EOF
:matchcontain
echo.
set curr=0&set exist=0
:scanchrloop
if "!str1:~%curr%,%length%!"=="" (
if !exist!==0 echo "%str1%" does not contain "%str2%".
goto :EOF
)
if "!str1:~%curr%,%length%!"=="!str2!" (
echo "%str1%" contains "%str2%". ^(in Position %curr%^)
set exist=1
)
set /a curr+=1&goto scanchrloop
:matchend
echo.
if "!str1:~-%length%!"=="!str2!" (
echo "%str1%" ends with "%str2%".
) else (
echo "%str1%" does not end with "%str2%".
)
goto :EOF
:str2_lngth
set length=0
:loop
if "!str2:~%length%,1!"=="" goto :EOF
set /a length+=1
goto loop
::/The functions.

View file

@ -0,0 +1,12 @@
@echo off
setlocal enableextensions enabledelayedexpansion
set /p a=
set /p b=
set /a i=0
for %%i in (^^%b% %b% %b%$) do (
echo/%a% | findstr /rc:"%%i" >nul 2>nul && set contain.!i!=Yes|| set contain.!i!=No
set /a i+=1
)
echo "%a%" starts with "%b%": %contain.0%
echo "%a%" ends with "%b%": %contain.1%
echo "%a%" contains "%b%": %contain.2%

View file

@ -0,0 +1,15 @@
@echo off
setlocal enableextensions enabledelayedexpansion
set /p a=
set /p b=
set "macroset=(set contain.M=Yes) else (set contain.M=No)"
:: https://ss64.com/nt/syntax-replace.html
call set "t=%%a:%b%=#%%"
if "#"=="%t:~0,1%" %macroset:M=0%
call set "t=%%a:*%b%=%%"
if ""=="%t%" %macroset:M=1%
call set "t=%%a:%b%=%%"
if not "%a%"=="%t%" %macroset:M=2%
echo "%a%" starts with "%b%": %contain.0%
echo "%a%" ends with "%b%": %contain.1%
echo "%a%" contains "%b%": %contain.2%

View file

@ -0,0 +1,16 @@
@echo off
setlocal enableextensions enabledelayedexpansion
set /p a=
set /p b=
call :getres startsWith.bat "%a%" "%b%"
echo "%a%" starts with "%b%": %result%
call :getres endsWith.bat "%a%" "%b%"
echo "%a%" ends with "%b%": %result%
set idx=
call indexOf.bat "%a%" "%b%" idx
echo "%a%" contains "%b%" at: %idx%
goto:eof
:getres
call %1 %2 %3 && set result=No||set result=Yes
goto:eof