Aviso: preg_match () [match.preg-match]: Modificador desconhecido
Estou recebendo esse erro ...
Aviso: preg_match () [match.preg-match]: modificador desconhecido '1' em C: \ path-to-plugin.php na linha 147
Quando executo a palavra-chave "Teste $ 2/1 test + word!" através da função abaixo
function my_get_kw_in_content($theKeyword, $theContent)
{
//ERROR OCCURS NEXT LINE
return preg_match('/\b' . $theKeyword . '\b/i', $theContent);
}
Estou assumindo que preciso limpar a palavra-chave para escapar do caractere "/" (e possivelmente mais). Agradeço todas as sugestões que você precisa para limpar a string antes de executá-la no preg_match.
ATUALIZAÇÃO: Isso parece funcionar graças ao tailandês:
function my_get_kw_in_content($theKeyword, $theContent)
{
$theKeyword = preg_quote($theKeyword, '/');
return preg_match('/\b' . $theKeyword . '\b/i', $theContent);
}