mwhiting has asked for the wisdom of the Perl Monks concerning the following question:

Hi - does anyone know if there is an easy way to make a regex pattern match ignore the accents on letters in other languages? For example, so that the word "café" and "cafe" would match (ie. ignore that the e's are actually different characters).

Thanks
Michael
  • Comment on making international characters generic

Replies are listed 'Best First'.
Re: making international characters generic
by graff (Chancellor) on Sep 20, 2007 at 03:20 UTC
    I posted this a while back, which might be helpful: Re^3: Removing Foreign Characters. There are other ways, of course, (I recall posting at least one other method myself), but that was the first one I found.

    Update: Found a couple more... this one's also a bit old: Re: Diacritic-Insensitive and Case-Insensitve Sorting, and this one (the most recent) is my favorite: Re: fill diacritic into text. Have fun.

    Another update: I realize I might be answering the wrong question -- and that's because there's some doubt about what your question really is. You say you're looking for

    an easy way to make a regex pattern match ignore the accents on letters in other languages? For example, so that the word "café" and "cafe" would match (ie. ignore that the e's are actually different characters).

    Um, so that "cafe" and "café" would match as opposed to what? The easiest way to make a regex ignore things is to use "." (e.g. /caf./ will match "cafe" and "café" and "cafè" and ... and caff and ...). How "exact" do you really need to be in your regex matching?

    Are you really looking for a way to remove accents so you can do an exact match (eq or ne) to an unaccented string? (That's sort of what my various cited nodes are about.)