批处理脚本:从字符串中提取数字

时间:2016-08-21 03:07:42

标签: regex string batch-file extract

我正在编写一个批处理脚本,我需要从字符串中提取数字(表示文件的版本),这样我就可以将它与另一个数字进行比较。 下面是我到目前为止编写的脚本

:: Over here I'm trying to extract number from the string , this isn't working
    for %%F in ("!name!\.." ) do (
    ::set "number=%%~nxF" |findstr /b /e /r "\"[0-9]*\"" 
    set res=%name:findstr /r "^[1-9][0-9]*$"
    echo !res!
    )

在最后两个for循环中,我实现了提取数逻辑,但它只打印The system cannot find the drive specified. 如果有人能帮助我解决这个问题,那将是一个很大的帮助。

0 个答案:

没有答案
相关问题