A "\" in a $regex causes The Mongo server and the Meteor query disagree


#1

Anyone else experienced this before?

{
...,
"$or":[
   {"name":{"$regex":"\\H","$options":"i"}},
   {"_id":{"$regex":"\\H","$options":"i"}}]
}

Any thoughts on why it would happen? Is Meteor trying to escape the H, or removing the “” perhaps?


#2

A quick note, running the query in meteor shell:

MyCollection.find({name: {$regex: "B", $options: "i"}}).fetch().length; \\ 1319

MyCollection.find({name: {$regex: "\\B", $options: "i"}}).fetch().length; \\6071

So it seems Meteor is doing something odd


#3

This looks like it should be posted as an issue on Github:


#4

Looks like the code that causes this might be here:


#5

I have created a github issue: https://github.com/meteor/meteor/issues/10340