my $string = 'http://172.20.37.115:8080/se/1.0/provision/subscribers/198968'; my ($wanted) = $string =~ m/ \d+$ /gx;