if ($input =~ m/^[A-Za-z]*\s{0,1}[A-Za-z]*$/) { print "match!\n"; } else { print "no match!\n"; }