Reputation: 47
I need a regular expression to use in preg_match that will catch words like cialis when as a word with spaces and also as a word with a tag up close ie <b>cialis</b>
, so I used this
$word = "cialis";
if (preg_match_all("/\b$word\b/i", $content, $matches)) {
$caught[] = $matches[0];
}
Which worked great and didn't fire with words like specialist that have cialis in them. All was fine until I hit some french words such as spécialisé The é is treated as if its a word boundary and so spécialisé gets caught. What regex would stop spécialisé being added to $caught?
Thank you in advance.
Upvotes: 1
Views: 111