/^\.?\d+\.\d+(?:\.\d+)*/ #### use strict; my $a = '1.3.6.1.2.1.1.3.0'; if ($a =~ /^\.?\d+\.\d+(?:\.\d+)*/) { print "match\n"; }