Quote:
Originally Posted by derfelix
find:
PHP Code:
$find[] = '/(\b'.$w.'\b)/i';
replace with:
PHP Code:
$find[] = '/('.preg_quote($w).')/iu';
BUT.. my question.. is there a drawback?????
Felix
|
Thanks, Felix. Indeed the problem is/was the word boundary. The drawback with removing the word boundary markers is that you end up highlighting substrings in the results which the search itself did not match.
For example, suppose you have a string "happily merrily sadly happilymerrilysadly" and you do a search for merrily
This should highlight as "happily
merrily sadly happilymerrilysadly"
and it does with the word boundary flags in the regex.
But without them, it highlights as "happily
merrily sadly happily
merrilysadly"
** Edited **
Can you try another way of solving the word boundary problem. Edit the loop in ldm_make_highlight_regex as follows:
Code:
foreach ($words AS $w) {
if ($w != "") {
$find[] = '/([\p{C}\p{P}\p{Z}]' . $w . '[\p{C}\p{P}\p{Z}]' . ')/iu';
$find[] = '/^(' . $w . '[\p{C}\p{P}\p{Z}]' . ')/iu';
$find[] = '/([\p{C}\p{P}\p{Z}]' . $w . '$)/iu';
}
}