Lab - $group and Accumulators regex not work in Compass

May I ask why does the regex in the official answer not work in Compass?
I get the error: Expected “[” or AggregationStage but “{” found.
I have tried escaping the parentheses, doesn’t work

I have tried and it works in the mongo shell.

I have done it using $and operator, which works in compass.


If you do not share what you tried to enter in Compass nobody can help.

Well, as said, I entered the regex from the official answer and I don’t think I can share it here.

Basically, in the $match stage in compass, I put
awards: regex

Try to update you command by one more closing brackets like this:

awards: { your regex code}

1 Like

Doesn’t work, and why would it?

@ danchann

The error you’re seeing is the standard Compass feedback whenever it doesn’t understand the query – you’ve got to keep editing your query until the error message goes away.

In this case, apparently Compass does not support the escape character ‘\d’ within the optional brackets type of PCRE. Try various alternatives if you really want to work on this, or query the Compass team directly. I’m going to consider this solved here.