RE question
Chris Radcliff
chris_radcliff at mac.com
Fri May 14 12:13:46 CDT 2004
~sdpm~
Hi Ken,
Regular expressions take time and practice. Hang in there. This may do
the trick:
$FORM{'subject'} =~ s/[^A-Za-z0-9.]//g;
Basically, "replace (s///) all (g) characters ([]) in $FORM{'subject'}
(=~) that aren't (^) A-Za-z0-9. with nothing."
I'm not sure if there's an advantage to using tr/// character
translation in this case. I tend to default to regex in case the
pattern needs to get more complex down the road.
Cheers,
~chris
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.
>
> 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.
>
> 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.
>
> If anyone can help, I'd appreciate it.
~sdpm~
The posting address is: san-diego-pm-list at hfb.pm.org
List requests should be sent to: majordomo at hfb.pm.org
If you ever want to remove yourself from this mailing list,
you can send mail to <majordomo at happyfunball.pm.org> 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 happyfunball.pm.org> .
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