my $ip = "csteppfw pts/0 2022-06-27 15:53 (192.168.5.100)"; my ( $match ) = $ip =~ /.*?(\d+\.\d+\.\d+\.\d+).*?/; print "$match\n";