If you wanted to do a boolean AND search for multiple words in the same field. I thought it would go something like this:
in the sub query in db.cgi
$finalreg = '';
foreach my $word (split /\s/, $in{'Fieldname'}) {
next if ($word =~ /^\s*$/);
$tmpreg = $word;
(!$in{'re'}) and ($tmpreg = "\Q$tmpreg\E");
($in{'ww'}) and ($tmpreg = "\\b$tmpreg\\b");
(!$in{'cs'}) and ($tmpreg = "(?i)$tmpreg");
$finalreg .= " m/$tmpreg/o &&";
}
chop $finalreg; chop $finalreg;
}
$regexp_func[$field] = eval "sub { $finalreg }";
}then
and finally
leave this the same, in sub query for other search criteria as well
$key_match = 0;
foreach $field (@search_fields) {
$_ = $values[$field]; # Reg function works on $_.
$in{'ma'} ?
($key_match = ($key_match or &{$regexp_func[$field]})) :
(&{$regexp_func[$field]} or next LINE);I thought this would work since its basically the keyword search with boolean mod. Its just that unlike the keyword boolean search filling up every field with the search criteria, this only uses the specific field in question with the search.
Unfortunately, I can't seem to get it to work, which is weird because the keyword boolean search works fine, but when I limit the search criteria to this one specific field, boom - no matching results. Not sure if it has anything to do with $regexp_func , cause I don't fully understand the function
Regular Expressions and pattern matching hurt my brain :)
Any thoughts
Trev
in the sub query in db.cgi
Code:
if($in{'FieldName'}) { $finalreg = '';
foreach my $word (split /\s/, $in{'Fieldname'}) {
next if ($word =~ /^\s*$/);
$tmpreg = $word;
(!$in{'re'}) and ($tmpreg = "\Q$tmpreg\E");
($in{'ww'}) and ($tmpreg = "\\b$tmpreg\\b");
(!$in{'cs'}) and ($tmpreg = "(?i)$tmpreg");
$finalreg .= " m/$tmpreg/o &&";
}
chop $finalreg; chop $finalreg;
}
$regexp_func[$field] = eval "sub { $finalreg }";
}
Code:
if($in{'Fieldname'}) { @values = ($line); #don't bother to splite_decode itleave this the same, in sub query for other search criteria as well
Code:
# Normal searches. $key_match = 0;
foreach $field (@search_fields) {
$_ = $values[$field]; # Reg function works on $_.
$in{'ma'} ?
($key_match = ($key_match or &{$regexp_func[$field]})) :
(&{$regexp_func[$field]} or next LINE);
Unfortunately, I can't seem to get it to work, which is weird because the keyword boolean search works fine, but when I limit the search criteria to this one specific field, boom - no matching results. Not sure if it has anything to do with $regexp_func , cause I don't fully understand the function
Regular Expressions and pattern matching hurt my brain :)
Any thoughts
Trev