Gossamer Forum
Home : General : Perl Programming :

Filtering Form Data

Quote Reply
Filtering Form Data
Hello,

I am trying to filter the data in a form's input field.

Specifically, I am trying to remove the TLD (.com,.net...) from a domain name.

For example, somone enters: gossamer-threads.com

I only want: gossamer-threads

I am working with the following code:

$domainname =~ s/\.[com|net|org]//i;
$page_html =~ s/%domainname%/$domainname/gi;


The problem is that the code returns: gossamer-threadsom (only stripping the .c of .com).

Any thoughts?

Sean
Quote Reply
Re: [skoenig] Filtering Form Data In reply to
Your syntax is wrong, try:

Code:
$domain =~ s/\.(?:com|net|org)$//i;
Quote Reply
Re: [Paul] Filtering Form Data In reply to
Thank you very much for your reply.

Your suggestion worked.

Best regards

Sean