how to check if a parameter (or variable) is numeric in windows batch file -


i need check if parameter passed windows batch file numeric or not.

i found below answer using "findstr" command regular expression: https://superuser.com/questions/404338/check-for-only-numerical-input-in-batch-file

i did try solution it's not working. (at least in windows 7 not working).

test scenarios:

aa  #not valid number a1  #not valid number 1a  #not valid number  11  #a valid number 

set "var="&for /f "delims=0123456789" %%i in ("%1") set var=%%i if defined var (echo %1 not numeric) else (echo %1 numeric) 

replace %1 %yourvarname% appropriate


Comments

Popular posts from this blog

javascript - Count length of each class -

What design pattern is this code in Javascript? -

hadoop - Restrict secondarynamenode to be installed and run on any other node in the cluster -