my $string = <28.56-1.22-4.104/02 EOT my $decimal = qr/[-+]?(?:\d+\.?\d*|\d*\.\d+)/; my ( $frst, $scnd ) = ( $string =~ /($decimal).*?($decimal)/ ); print "$frst, $scnd\n";