im running a command to get the version of a program.
FOR /F "tokens=* USEBACKQ" %%F IN (`"%programpath%\bin\program" version`) DO ( set version_full=%%F )
Program Final Type 6.6.8 (build v3425fw2f24)
The Program Final Type part can vary. There are different types of this program. Hence why I need to use regex to find the version.
I need to get just the 6.6.8 out of this string and set it to a variable called "version_num". But I actually want it to be 188.8.131.52 if its only three numbers.
Sometimes the version can be 4 digits... like 184.108.40.206. I need to get all 4 numbers if 4 .. or if 3 make it 4 by adding a 0 at the end.
findstr /R "[0-9].[0.9].[0.9]" %version_full%
But i just get the entire string separated I think byspaces in an error like this:
FINDSTR: Cannot open 6.6.8
So its obviously not finding it.
I've gotten this to work to tell me if its found or not found, but I still cant get the actual found value into a variable.
@echo off set var1=Program One New 6.6.8 (build ee27a8rr43e) set "regexp=.*[0-9].[0-9].[0-9].*" echo %var1% echo %regexp% echo %var1%|findstr /r /C:"%regexp%" >nul 2>&1 && echo Found || echo Not found. Found