On Mon, 27 Jan 2003, Liebert, Sander wrote:
> Date: Mon, 27 Jan 2003 12:54:04 -0600
> From: "Liebert, Sander" <[EMAIL PROTECTED]>
> To: [EMAIL PROTECTED]
> Subject: Regular Expression's and punctuation
>
> 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.
>
>
"punctuation characters" are usually called meta-characters.
If you're so inclinded you "escape" them like so:
$target =~ s/([;+<>\*\|`&\$!#\(\)\[\]\{\}:'"])/\\$1/g;
>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.
>
If you're only concerned with the existence of the data, and nothing
more:
if(! $b) { $error .= "Enter a message <br> \n"; }
>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,
>
Can I recommend Friedl's Mastering Regular Expression. It's one of
those required reads for any serious Perl Hack0r.
jab
>
>
> --
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
--------
Be straight and to the point. Don't waste others' time.
Do your homework before you ask for help.
--Unknown
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]