0
set %some1 (2)
set %some2 (3)

现在我可以获取括号中 some1 的值并使用 $regsubex 将其更改为其他值
所以任何人都可以提供帮助吗?

4

1 回答 1

0

您可以使用$regex()获取括号内的数值:

; find the value
noop $regex(%some1, (\d+))

; print the value
echo -a Value: $regml(1)

将打印:

2

同样,您可以使用相同的正则表达式,但$regsub()这次更改该值:

; replace the value inside the () and put it back in %some
noop $regsub(%some1, (\d+), 98765, %some1)

; print that value
echo -a %some1

将打印:

(98765)
于 2013-04-08T15:01:44.687 回答