$ perl -le ' > print > qq{->$_<-: }, > m{(?x) ^ (?: \z | (?> \s* ) \D ) } > ? q{matches} > : q{no match} > for q{}, q{12ab}, q{cat}, q{ 99balloons}, q{ dog};' -><-: matches ->12ab<-: no match ->cat<-: matches -> 99balloons<-: no match -> dog<-: matches $