This adds a checkbox after the search textfield, for whole word only search. Based on 1.0 --
JeffDonner
The search should be bracketed with \b and not \W. Otherwise, it will fail to match at the beginning or end of a line. --
ChuckAdams
> if (($Text{'text'} =~ /$pattern/i) || ($name =~ /$pattern/i)) {
instead of
> if (($Text{'text'} =~ /$pattern/i) || ($name =~ /$string/i)) {
so wordsearch for titles too.
--
JuanmaMP
1500a1501,1502
> $result .= ' ' . $q->checkbox(-name=>'wordsearch', -default=>'checked', -label=>'word');
>
3086c3088
< my ($id, $action, $text, $search);
---
> my ($id, $action, $text, $search, $wantword);
3156a3159
> $wantword = &GetParam("wordsearch", "");
3158c3161
< &DoSearch($search);
---
> &DoSearch($search, $wantword);
3714c3717
< my ($string) = @_;
---
> my ($string, $wantword) = @_;
3718c3721,3725
< return;
---
> } else {
> print &GetHeader('', &QuoteHtml(Ts('Search for: %s', $string)), '');
> print '<br>';
> &PrintPageList(&SearchTitleAndBody($string, $wantword));
> print &GetCommonFooter();
3720,3723d3726
< print &GetHeader('', &QuoteHtml(Ts('Search for: %s', $string)), '');
< print '<br>';
< &PrintPageList(&SearchTitleAndBody($string));
< print &GetCommonFooter();
3735c3738
< &PrintPageList(&SearchTitleAndBody($string));
---
> &PrintPageList(&SearchTitleAndBody($string, 1));
4103c4106
< my ($string) = @_;
---
> my ($string, $wantword) = @_;
4109c4112,4113
< if (($Text{'text'} =~ /$string/i) || ($name =~ /$string/i)) {
---
> my $pattern = $wantword ? "\\W$string\\W" : $string;
> if (($Text{'text'} =~ /$pattern/i) || ($name =~ /$string/i)) {