Notepad ++搜索并替换多个文本行
我有多行,如下面的
示例:
set srcaddr "10.68.0.244/32" "172.29.54.0/25" "PING" permit log set
srcaddr "172.21.24.110/32" "172.29.44.36/32" "udp-5499" permit log
set srcaddr "10.211.245.0/26" "172.29.35.201/32" "SSH" permit log
此声明中的IP地址>>设置srcaddr“10.68.0.244/32”不是固定的数字,它在其他行中改变。
我想这样做
set srcaddr "10.68.0.244/32"
set dstaddr "172.29.54.0/25" "PING" permit log
答案 0 :(得分:0)
我会尝试搜索:
srcaddr(\W+)("[0-9\.\/-]+")\W+("[0-9\.\/-]+")(\W+)"
并将其替换为:
srcaddr\1\2\nset dstaddr\1\3\4"
这对我来说很有用。
输入:
set srcaddr "10.68.0.244/32" "172.29.54.0/25" "PING" permit log
set srcaddr "172.21.24.110/32" "172.29.44.36/32" "udp-5499" permit log
set srcaddr "10.211.245.0/26" "172.29.35.201/32" "SSH" permit log
set srcaddr "172.29.35.201/32" "10.74.79.0/27" "tcp-22" permit log
set srcaddr "172.29.44.0/24" "172.20.250.0/24" "PING" permit log
set srcaddr "172.29.35.1/32" "172.21.24.0/24" "tcp-12001" permit log
set srcaddr "172.29.41.0/24" "10.32.125.50-150" "HTTP" permit log
输出:
set srcaddr "10.68.0.244/32"
set dstaddr "172.29.54.0/25" "PING" permit log
set srcaddr "172.21.24.110/32"
set dstaddr "172.29.44.36/32" "udp-5499" permit log
set srcaddr "10.211.245.0/26"
set dstaddr "172.29.35.201/32" "SSH" permit log
set srcaddr "172.29.35.201/32"
set dstaddr "10.74.79.0/27" "tcp-22" permit log
set srcaddr "172.29.44.0/24"
set dstaddr "172.20.250.0/24" "PING" permit log
set srcaddr "172.29.35.1/32"
set dstaddr "172.21.24.0/24" "tcp-12001" permit log
set srcaddr "172.29.41.0/24"
set dstaddr "10.32.125.50-150" "HTTP" permit log