$Gateway = "192.168.122.1"
$Ip = "172.18.66.34"
My goal is to get the output as below.
172.18.66.1
1st 3 octet of $IP and 4th octet of $Gateway....combination of both...
I tried below but its not working any other logic to achieve this
$Gateway -match "\d{1,3}\.\d{1,3}\.\d{1,3}\.(?<content>)"
$fourth = $matches['content']
$mgmt = "172.18.47.19"
$mgmt -match "\d{1,3}\.\d{1,3}\.\d{1,3}\.(?<content>.*)"
$new = $matches['content']
$mgmt.replace($new,$fourth)
Maybe Primitive, but does the job
works on powershell 2
is that what you mean?