Welcome to WebmasterWorld Guest from 126.96.36.199
I'm trying to highlight words in a string via regex. I not only want to highlight the singular word e.g. "word" but also plurals like "words" and "word's".
This is easy to do, but some strings use entities to represent single quotes, such as ’ and ’. This is were my problem is, because it appears & is being treated as an operator, instead of plain character.
I came up with a simple version that doesn't work:
$find = '/([^a-zA-Z0-9])(' . $keyword . 's¦' . $keyword . '\'s¦' . $keyword . '’s¦' . $keyword . '’s' . $keyword . ')([^a-zA-Z0-9])/i';
$replace = "\$1<b>\$2</b>\$3";
Any one know how i can get the regex parser to not interpret & as an operator?