How do I get a character position from a string in a batch

I have a string of results stored in a variable RES, this result is similar to 2.3/5.0. I would like to get the part to " /" and send it to batch output through the ECHOcommand. I was looking for how to do this using command commands, but I get only the results so that the substring is fixed, but how can I find out this position? If I knew the position, the only thing I have to do is:

ECHO %RES:~0,pos%

Then the question arises: how do I get this position from a string? Thanks

+4
source share
2 answers

, strlen ? , , :

set "res=2.3/5.0"
for /f "tokens=1 delims=/" %%i in ("%res%") do (set prefix=%%i)
+5

, ?

for /f "delims=/" %%i in ("%RES%") do echo %%i
+4

Source: https://habr.com/ru/post/1527977/


All Articles