RE question

Dave Roe david_roe at
Fri May 14 12:29:34 CDT 2004

On May 14, 2004, at 9:31 AM, Ken Loomis wrote:

> As a web designer that enjoys programming, I joined this group a few 
> years ago hoping to become proficient at PERL (or, is it Perl). I have 
> learned a lot from looking at the exchanges here, but have to admit 
> that RE's still baffle me.

It's Perl. You can learn a lot more at and/or perldoc.

> I host a discussion board that is apparently being Spam'ed by hackers. 
> The board is in Perl and I would like an RE that will strip everything 
> except alphanumeric characters from the subject. For example, the 
> subject line should only contain A-Z, a-z & 0-9.

 From perldoc perlre:

            \w  Match a "word" character (alphanumeric plus "_")
            \W  Match a non-"word" character

> The subject line is contained in $FORM('subject'), so I'd like an RE 
> that will replace the contents of that variable with the stripped 
> version. also, I may decide to allow periods ('.'), and would like to 
> see how I'd have to modify that RE to allow that.

You probably meant $FORM{'subject'}. How about:

	$FORM{subject} =~ s/\W//g;

which means "change a non-word char into nothing, repeatedly".

	$FORM{subject} =~ s/[^\w\.]//g

uses a character class to change anything that is _not_ a word char or 
a period into nothing.

Seriously, read perldoc. Start with "perldoc perlrequick" and "perldoc 



The posting address is: san-diego-pm-list at

List requests should be sent to: majordomo at

If you ever want to remove yourself from this mailing list,
you can send mail to <majordomo at> with the following
command in the body of your email message:

    unsubscribe san-diego-pm-list

If you ever need to get in contact with the owner of the list,
(if you have trouble unsubscribing, or have questions about the
list itself) send email to <owner-san-diego-pm-list at> .
This is the general rule for most mailing lists when you need
to contact a human.

More information about the San-Diego-pm mailing list