I have 2 variables "number" and "some":
我有两个变量“数字”和“一些”:
SET number=12
SET some=25
How can I invoke digits from those variables to use it in regexp? Something like:
如何调用这些变量中的数字以在regexp中使用它?就像是:
%number(0)% [0 - %number(1)%] | %some(0)% [0 - %some(1)%]
1 个解决方案
#1
2
I don't understand what you mean by "invoke digits" but if you just want to get the digits then it depends on how the numbers are.
我不明白你的意思是“调用数字”,但如果你只是想得到数字,那么它取决于数字的方式。
If they're fixed-width (like always have 2 digits) you can use variable substring to get the digits
如果它们是固定宽度(如总是有2位数),则可以使用变量子串来获取数字
echo %number:~0,1% %number:~1,1%
If the numbers have variable width then you need to do some math with set /a
如果数字的宽度可变,那么你需要用set / a做一些数学运算
set /a tens=(number/10) %% 10
set /a ones=number %% 10
Same thing if you want to do math like 0 - %number(1)%
above
同样的事情,如果你想做数学,如0 - %数(1)%以上
#1
2
I don't understand what you mean by "invoke digits" but if you just want to get the digits then it depends on how the numbers are.
我不明白你的意思是“调用数字”,但如果你只是想得到数字,那么它取决于数字的方式。
If they're fixed-width (like always have 2 digits) you can use variable substring to get the digits
如果它们是固定宽度(如总是有2位数),则可以使用变量子串来获取数字
echo %number:~0,1% %number:~1,1%
If the numbers have variable width then you need to do some math with set /a
如果数字的宽度可变,那么你需要用set / a做一些数学运算
set /a tens=(number/10) %% 10
set /a ones=number %% 10
Same thing if you want to do math like 0 - %number(1)%
above
同样的事情,如果你想做数学,如0 - %数(1)%以上