开发者

MongoDB regex query to find unicode replacement character

开发者 https://www.devze.com 2023-04-08 19:17 出处:网络
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

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/});

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号