REGEX GROUP cuts off data
-
I’m using the following regex to find an IP address in ‘slash’ notation.
String = D EX 192.168.254.0/24 [170/1252608] via 172.29.104.5, 3w0d, Vlan104
Regex = (([0-2]?[0-9]?[0-9].){3}([0-2]?[0-9]?[0-9])/[1-3]?[1-9])When I find using the regex it matches. However, when I select ‘\1’ for replace (without quotes) to keep just the group match, the IP address has digits removed. For example, if the IP address were a 10.x network the result returns 0.x and cuts off the ‘1’. If the address is 172.16.x it cuts off the ‘172’. If I change the regex to explicitly expect 10.x, 172.x, 192.x, etc. it works fine.
Regex = ^.(10.([0-2]?[0-9]?[0-9].){2}([0-2]?[0-9]?[0-9])/[1-3]?[1-9]).$
Regex = ^.(172.([0-2]?[0-9]?[0-9].){2}([0-2]?[0-9]?[0-9])/[1-3]?[1-9]).$
Regex = ^.(192.([0-2]?[0-9]?[0-9].){2}([0-2]?[0-9]?[0-9])/[1-3]?[1-9]).$ -
Hello @spickles
one thing might be that you did not escape the forward slash !?
But the replace … you want to replace the part which is found with the part which is found … ???Cheers
Claudia