php - regex to also match accented characters -
i have following php code:
$search = "foo bar que"; $search_string = str_replace(" ", "|", $search); $text = "this foo text qué , other accented characters."; $text = preg_replace("/$search_string/i", "<b>$0</b>", $text); echo $text;
obviously, "que" not match "qué". how can change that? there way make preg_replace
ignore accents?
the characters have match (spanish):
á,Á,é,É,í,Í,ó,Ó,ú,Ú,ñ,Ñ
i don't want replace accented characters before applying regex, because characters in text should stay same:
"this foo text qué , other accented characters."
and not
"this foo text que , other accented characters."
$search = str_replace( ['a','e','i','o','u','ñ'], ['[aá]','[eé]','[ií]','[oó]','[uú]','[nñ]'], $search)
this , same upper case complain request. side note: ñ
replacemet sounds invalid me, 'niño' totaly diferent 'nino'
Comments
Post a Comment