MongoDB 正则表达式查询以查找 unicode 替换字符 [英] MongoDB regex query to find unicode replacement character

查看:49
本文介绍了MongoDB 正则表达式查询以查找 unicode 替换字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试手动修复 Mongo 数据库中包含 Unicode 替换字符的一些文档(看起来像一个问号,请参阅 http://www.fileformat.info/info/unicode/char/fffd/index.htm).我已经解决了为什么这些字符会出现在那里但也想保留旧数据的问题.所以我想要的只是一个简单的查询,它返回包含这个字符的所有文档.

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.

目前我想到的是

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

查找艺术家名中包含替换字符的所有歌曲.到目前为止没有运气.

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

推荐答案

似乎它不喜欢正则表达式中的 \uXXXX.试试:

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

db.songs.find({artist: new RegExp("\ufffd")});

这篇关于MongoDB 正则表达式查询以查找 unicode 替换字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆