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 contain开发者_如何学Cing 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.
Seems it doesn't like \uXXXX
in the regexp. Try:
db.songs.find({artist: new RegExp("\ufffd")});
To bump an old thread :D for regex you need to escape the backslash otherwise it will escape the u instead:
db.songs.find({artist: /\\ufffd/});
精彩评论