Gossamer Forum
Home : Products : Links 2.0 : Customization :

Replace in search phrase

Quote Reply
Replace in search phrase
Hello,

I need to remove some parts of search phrase entered by user. In the concrete I need to remove the "www." and ".com" from "www.somedomain.com" because for "www.somedomain.com" there are no results but for "somedomain" there are! I tried to put this near the beginning of search.cgi:

foreach $term (@search_terms) {
$term =~ s/www//;
$term =~ s/com//;
}

But it did nothing. The search phrase stayed unmodified.
I also tried to search through this forum, but found nothing.

Does anybody knows how to solve it?

Zdenek
Prospector's free stuff - http://www.prospector.cz/
Quote Reply
Re: [Prospector] Replace in search phrase In reply to
Maybe...

foreach $term (@search_terms) {
$term =~ tr|www||;
$term =~ tr|\.com||;
}


Leonard
aka PerlFlunkie
Quote Reply
Re: [PerlFlunkie] Replace in search phrase In reply to
Hi Leonard,

thanks for your support. I tried it, but had no luck. Still doesn't works :( I tried it on many different places in the search.cgi and nothing. But I'm not too strong in Perl so maybe I'm not changing the right variable ...

Zdenek
Prospector's free stuff - http://www.prospector.cz/
Quote Reply
Re: [Prospector] Replace in search phrase In reply to
Try...

sub main {
# --------------------------------------------------------
%in = &parse_form();
# Display the form if called with no input.
(keys %in <= 0) and &site_html_search_form() and return;

$in{'query'} =~ s/www//;
$in{'query'} =~ s/com//;



Leonard
aka PerlFlunkie
Quote Reply
Re: [PerlFlunkie] Replace in search phrase In reply to
Thank you so much! It works perfectly.

Zdenek
Prospector's free stuff - http://www.prospector.cz/