Liebert, Sander wrote: > I have a script that is used for text messaging. I added a line of > code to check to make sure that input is in a field before the > message is sent. My code is as follows: > > if($b !~ m/^\w[\w\s]*\w$/) { $error .= "Enter a message <br> \n"; } > > This fails if the field has any punctuation characters. I have > checked on www.perldoc.com but I seem to be going in the wrong > direction. I only want it to check to make sure there is data in the > field. I am not concerned with what the data is. This is only to keep > people from sending blank messages. My thought is that it's one of > these, but I am not sure. \w, \W, \s, \S, \d,
It depends on how you define "blank". A simple test is: $error = "Message required" unless $text =~ /\S/; This says that $text must contain at least one non-whitespace char. If you want it to contain at least one letter, you could use: $error = "Message required" unless $text =~ /[:alpha:]/; Or one "word" character (letter, digit, underscore) $error = "Message required" unless $text =~ /\w/; -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]