Hi,
I've been thinking about my search facility and decided to add some matched text highlighting.
However, i'm currently using the search term as the replacement text, and as I am doing patrial 'LIKE' match, the text may be in the middle of a word, as I am using CSS to transform the font to capitalize, it's making the highlighting look odd when the replacement is done.
ok I could remove the CSS, but I still have the problem currenly if I simply use the search text and someone types as their search
so the question...
How do I do a substitute interpolating the search term and required replacement markup , but it use the text found in the string to keep its character set intact.
current code...
"In complete darkness we are all the same, only our knowledge and wisdom separates us, don't let your eyes deceive you."
"If a shortcut was meant to be easy, it wouldn't be a shortcut, it would be the way!
I've been thinking about my search facility and decided to add some matched text highlighting.
However, i'm currently using the search term as the replacement text, and as I am doing patrial 'LIKE' match, the text may be in the middle of a word, as I am using CSS to transform the font to capitalize, it's making the highlighting look odd when the replacement is done.
ok I could remove the CSS, but I still have the problem currenly if I simply use the search text and someone types as their search
it replaces the text with the upper and lower case as it's typed.DaNcE MuSiC
so the question...
How do I do a substitute interpolating the search term and required replacement markup , but it use the text found in the string to keep its character set intact.
current code...
Code:
# get albums
my @albums = &getSQL("Albums","*","$sql","Rec_ID DESC");
my $i = @albums+1;
[b]my $replace = "<span class=\"red\">$search</span>";[/b]
#loop album and build track listing
for(@albums){
$i--;
my @tracks = &getSQL("Tracks","*","Album = '$_->{'Album_Title'}' AND Artist = '$_->{'Artist'}'","Track_No ASC");
foreach my $trk(@tracks){
$trk->{'Disp_Title'} = $trk->{'Track_Title'};
[b]if($search ne ""){
$trk->{'Disp_Title'} =~ s/$search/$replace/gi
}[/b]
}
$_->{'Tracks'} = \@tracks;
$_->{'CNT'} = $i;
$_->{'Disp_Title'} = $_->{'Album_Title'};
$_->{'Disp_Artist'} = $_->{'Artist'};
$_->{'Disp_Genre'} = $_->{'Genre_Desc'};
[b]if($search ne ""){
$_->{'Disp_Title'} =~ s/$search/$replace/gi;
$_->{'Disp_Artist'} =~ s/$search/$replace/gi;
$_->{'Disp_Genre'} =~ s/$search/$replace/gi;
}[/b]
}
"In complete darkness we are all the same, only our knowledge and wisdom separates us, don't let your eyes deceive you."
"If a shortcut was meant to be easy, it wouldn't be a shortcut, it would be the way!