【发布时间】:2011-12-31 01:46:59
【问题描述】:
我想将一个函数调用(它返回一个字符串)作为替换字符串传递给 Powershell 的替换函数,以便将找到的每个匹配项替换为不同的字符串。
有点像 -
$global_counter = 0
Function callback()
{
$global_counter += 1
return "string" + $global_counter
}
$mystring -replace "match", callback()
Python 通过 're' 模块的 'sub' 函数实现这一点,该函数接受回调函数作为输入。寻找类似的东西
【问题讨论】:
标签: powershell replace