Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/mongodb/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Regex 在Mongo数据库v3.0.11中搜索空终止字符?_Regex_Mongodb_Pcre_Aws Documentdb - Fatal编程技术网

Regex 在Mongo数据库v3.0.11中搜索空终止字符?

Regex 在Mongo数据库v3.0.11中搜索空终止字符?,regex,mongodb,pcre,aws-documentdb,Regex,Mongodb,Pcre,Aws Documentdb,我们在MongoDB实例中有许多包含空终止字符的字符串,我们需要找到哪些字符串是空终止字符。知道Mongo使用PCRE Regex,我们找到()匹配空终止字符的正确语法,并像这样搜索它: db.updates\u v2.find({'longDescription':/.*\x00.*/}).count() 但是,这将返回0。我们知道其中有空终止字符,因为在迁移到DocumentDB的过程中,它拒绝接受它们。此外,我们还运行了以下查询,确认longDescription是罪魁祸首: db.upd

我们在MongoDB实例中有许多包含空终止字符的字符串,我们需要找到哪些字符串是空终止字符。知道Mongo使用PCRE Regex,我们找到()匹配空终止字符的正确语法,并像这样搜索它:

db.updates\u v2.find({'longDescription':/.*\x00.*/}).count()

但是,这将返回
0
。我们知道其中有空终止字符,因为在迁移到DocumentDB的过程中,它拒绝接受它们。此外,我们还运行了以下查询,确认
longDescription
是罪魁祸首:

db.updates_v2.find().forEach(function(doc){
... for (var key in doc) {
...     if ( /.*\x00.*/.test(doc[key]) )
... print(key)
... }
... });
longDescription
longDescription
longDescription
...
我还测试了节点中的正则表达式(尽管是不同的正则表达式引擎):

从mongodb迁移到aws documentdb时会出现此问题,因为后者不接受字符串中的\0个字符


我们确实需要能够可靠地提取这些内容,以便创建一个脚本,该脚本可以
查找
有问题的条目,删除空字符并
更新
条目。有什么想法吗?

因为最近我们看到了一些观点:我们从未找到解决方案,它阻止我们从MongoDB迁移。因为最近看到了一些观点:我们从未找到解决方案,它阻止我们从MongoDB迁移。
> test = "wot wot in the \0"
'wot wot in the \u0000'
> test2 = "wot wot in the wat"
'wot wot in the wat'
> regex = /.*\x00.*/
> test2.match(regex)
null
> test.match(regex)
[ 'wot wot in the \u0000',
  index: 0,
  input: 'wot wot in the \u0000',
  groups: undefined ]