my $str = "2006-01-30 10:11:08.507"; if($str =~ /-(.*?)-/) { print "Month is $1\n"; }