Hi all,
I've a searchfunction for a part of the database which is (most of the times) a large amount of text. The searchfunction works great but I only want to parse out the part of the text where the searchwords are found in. That also works for a one word-search, when I use this code:
The foreach $line (@searchterms) makes the searchterm bold up. But I also want this to work for a double word-search, like double date. If those two words are not next to eachother in the text, it won't show up. So what I would like is something like this:
so that it will search in the text foreach $line in the @searchterms and not only for the combination of those two words.
I hope that you can help me with this. You've proven to be the best place for help with these kinds of problems before.
I've a searchfunction for a part of the database which is (most of the times) a large amount of text. The searchfunction works great but I only want to parse out the part of the text where the searchwords are found in. That also works for a one word-search, when I use this code:
Code:
my $string = $linkinfo[3];
my $length = 200;
my $fragment = substr $string, (index($string, $search) - 15), $length;
my $fragment = "...$fragment...";
foreach $line (@searchterms) {
$fragment =~ s/($line)/<b>$1<\/b>/ig;
}
Code:
foreach $line (@searchterms) {
my $string = $linkinfo[3];
my $length = 200;
my $fragment = substr $string, (index($string, $search) - 15), $length;
my $fragment = "...$fragment...";
$fragment =~ s/($line)/<b>$1<\/b>/ig;
}
I hope that you can help me with this. You've proven to be the best place for help with these kinds of problems before.