#!/usr/bin/perl -w use strict; my $number = "..2314-1234123."; if ($number =~ /^((?:[0-9\.-]*)(?:[0-9]+)(?:[0-9\.-]*))$/) { print "$1\n"; }