#!/usr/bin/perl -lw use strict ; my $d = "2005-12-" ; if ( $d =~ /\d{4}-\d{1,3}(?!-)/ ) { print "yep" ; } #### \d{4}-\d{1,3}(?!-)$ \d{4}-\d{2}(?!-)