Regex to ignore accents? PHP

后端 未结 5 967
名媛妹妹
名媛妹妹 2020-12-06 10:50

Is there anyway to make a Regex that ignores accents?

For example:

preg_replace(\"/$word/i\", \"$word\", $str);

5条回答
  •  醉梦人生
    2020-12-06 11:36

    Java and Jávã are different words, there's no native support in regex for removing accents, but you can include all possible combinations of characters with or without accents that you want to replace in your regex.

    Like preg_replace("/java|Jávã|jáva|javã/i", "$word", $str);.

    Good luck!

提交回复
热议问题