Is there a way to use preg_match
(e.g. perhaps via a flag) to do diacritic-insensitive matches?
For example, say I'd like it to match:
- cafe
- café
I know I can do a regex like this: caf[eé]
. This regex will work as long as I don't come across any other diacritic variations of e
, like: ê è ë ē ĕ ě ẽ ė ẹ ę ẻ
.
Of course, I could just list all of those diacritic variations in my regex, such as caf[eêéèëēĕěẽėẹęẻ]
. And as long as I don't miss anything, I'll be good. I would just need to do this for all the letters in the alphabet, which is a tedious and prone-to-error solution.
It is not an option for me to find and replace the diacritic letters in the subject with their non-diacritic counterparts. I need to preserve the subject as-is.
The ideal solution for me is to have regex to be diacritic-insensitive. With the example above, I want my regex to simply be: cafe
. Is this possible?