Warning: preg_match () [function.preg-match]: modificador desconocido
Recibo este error ...
Warning: preg_match () [function.preg-match]: Modificador desconocido '1' en C: \ path-to-plugin.php en la línea 147
Cuando ejecuto la palabra clave "Test $ 2/1 test + word!" a través de la función a continuación
function my_get_kw_in_content($theKeyword, $theContent)
{
//ERROR OCCURS NEXT LINE
return preg_match('/\b' . $theKeyword . '\b/i', $theContent);
}
Supongo que necesito desinfectar la palabra clave para escapar del carácter "/" (y posiblemente más). Agradecería cualquier sugerencia que tenga para desinfectar la cadena antes de ejecutarla en preg_match.
UPDATE: Esto parece funcionar gracias a Thai:
function my_get_kw_in_content($theKeyword, $theContent)
{
$theKeyword = preg_quote($theKeyword, '/');
return preg_match('/\b' . $theKeyword . '\b/i', $theContent);
}