/^\d{4}\-\d{2}$/ or die; # match on end of string after \d{2}, or ... /^\d{4}\-\d{2}\s+/ or die; # match on whitespace delimiter # etc.