$str = 'This sentence has two numbers, +13 and -15.'; $str =~ /([+-]?\d+)/; # matches +13, first match found $str =~ /.*([+-]?\d+)/; # matches -15 because .* is greedy