Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MongoDB regex query to find unicode replacement character

I am trying to manually fix some documents in my Mongo database which contain the Unicode replacement character (looks like a question mark, see http://www.fileformat.info/info/unicode/char/fffd/index.htm). I already fixed the issue why these characters ended up there but would like to keep the old data too. So all I want is a simple query which returns all documents containing this character.

What I came up with so far is

db.songs.find({artist: /\ufffd/});

to find all songs with an artist name containing the replacement character. No luck so far.

like image 460
mbuchetics Avatar asked Oct 27 '25 02:10

mbuchetics


1 Answers

Seems it doesn't like \uXXXX in the regexp. Try:

db.songs.find({artist: new RegExp("\ufffd")});
like image 115
pingw33n Avatar answered Oct 28 '25 18:10

pingw33n