社区讨论
:global searep ={:local input [:tostr $1];:本地搜索[:tostr $2];:local replace [:tostr $3]:local start -1;: localtmppos 0;:本地sx "";:local dx" ":while ([:typeof [:find $input $search $start]] = "num") do={:set tmppos [:find $input $search $start]:set sx [:pick $input 0 $tmppos]:set dx [:pick $input ($tmppos + [:len $search]) [:len $input]]:set start ([:len "$sx$replace"] - 1):set input "$sx$replace$dx"}:return $input}
/interface {:local searchthis "WORDBEFORE":local replcwthis "WORDAFTER":foreach item in=[find where !dynamic and type="ether" and comment~$searchthis] do={:put [get $item comment] set $item comment=[$searep [get $item comment] $searchthis $replcwthis]:put [get $item comment]}}
搜索和替换功能: 代码:选择所有 :global searep do={:本地输入[:tostr $1]:本地搜索[:tostr $2]:本地替换[:tostr $3]:本地开始-1;: localtmppos 0;:本地sx "";:local dx" ":while ([:typeof [:find $input $search $start]] = "num") do={:set tmppos [:find $input $search $start]:set sx [:pick $input 0 $tmppos]:set dx [:pick $input ($tmppos + [:len $search]) [:len $input]]:set start ([:len "$sx$replace"] - 1):set input "$sx$replace$dx"}:return $input} 如何使用该函数:示例代码 /interface {:local searchthis "WORDBEFORE":local replcwthis "WORDAFTER":foreach item in=[find where !dynamic and type="ether" and comment~$searchthis] do={:put [get $item comment] set $item comment=[$searep [get $item comment] $searchthis $replcwthis]:put [get $item comment]}}
:global searep do={:本地输入[:tostr $1]:本地搜索[:tostr $2]:本地替换[:tostr $3]:本地开始-1;: localtmppos 0;:本地sx "";:local dx" ":while ([:typeof [:find $input $search $start]] = "num") do={:set tmppos [:find $input $search $start]:set sx [:pick $input 0 $tmppos]:set dx [:pick $input ($tmppos + [:len $search]) [:len $input]]:set start ([:len "$sx$replace"] - 1):set input "$sx$replace$dx"}:return $input}
In =[find where !dynamic and type="ether" and comment~$searchthis]
检查以下三个条件是否满足: 代码:选择所有 In =[find where !dynamic and type="ether" and comment~$searchthis] BR。
:foreach item in=[/interface find where !dynamic and type="ether" and comment~"WORDBEFORE"] do={:put [/interface get $item comment]}
是将函数和示例都粘贴到终端上,还是只粘贴使用函数的示例? 如果不先粘贴这个功能,怎么用呢? 这个也有空白结果吗? 代码:选择所有 :foreach item in=[/interface find where !dynamic and type="ether" and comment~"WORDBEFORE"] do={:put [/interface get $item comment]}
/interface {:local searchthis "WORDBEFORE":local replcwthis "WORDAFTER":foreach item in=[/interface find where !dynamic and type="ether" and comment~"WORDBEFORE"] do={:put [/interface get $item comment]}:put [get $item comment] set $item comment=[$searep [get $item comment] $searchthis $replcwthis]:put [get $item comment]}}
你读了你引用的东西吗? 你必须同时使用这两个脚本,或者为什么我写的函数在例子中,无用的?