0

I need to be able to find accented strings like "Błachowicz", "Jędrzejczyk", "Bęben" with "Blachowicz", "Jedrzejczyk", "Beben"

The accents are from Polish language, the strings are in Mongo database.

I tried db.fighters.find({ surname: { $regex: new RegExp(".*" + 'Blachowicz' + ".*", "i") } } ) but it doesn't work.

youbetternot
  • 2,566
  • 2
  • 17
  • 20
  • 1
    There's nothing built into JavaScript to do this. You'll need a library of some kind (recommendations for which are off-topic for SO). Or, of course, use character classes, e.g. `/B[ęe]ben/` or alternations if it's more complicated than that (as it is in German): `/B(?:ę|e)ben/` But presumably that gets complex fast. – T.J. Crowder Oct 02 '16 at 17:33
  • 1
    I guess you may need to use a library like [Latinize](https://www.npmjs.com/package/latinize) for this job. Well if you look at it's [code](https://github.com/dundalek/latinize/blob/master/latinize.js) you will see that it's just a huge look up object. You might even copy that too... – Redu Oct 02 '16 at 17:37
  • Thank for help guys, I ended up keeping both versions in database, with accents and without. – youbetternot Oct 02 '16 at 20:21

0 Answers0