I have the following PHP code:
$search = "foo bar que";
$search_string = str_replace(" ", "|", $search);
$text = "This is my foo text with qué and other accented characters.";
$text = preg_replace("/$search_string/i", "<b>$0</b>", $text);
echo $text;
Obviously, que does not match qué. How can i change this? Is there any way to preg_replaceignore all accents?
Characters to match (Spanish):
á,Á,é,É,í,Í,ó,Ó,ú,Ú,ñ,Ñ
I do not want to replace all characters with an accent before applying the regular expression, because the characters in the text must remain unchanged:
"This is my text foo with qué and other accented characters."
but not
"This is my text foo with que and other accented characters."
source
share