http://www.perlmonks.org?node_id=1012732


in reply to Detecting if a string is a regular expression

You could create a regex that checks the string for the characters you want to allow, e.g.:

sub isStrOK { return $_[0] =~ /\A[\s\w]+\z/; }

The above's not intended to be exhaustive for allowable characters, but only an example.