MongoDb does not support the dotall 's' flag from Perl Compatible Regular Expressions.
This flag makes the '.' dot character match really all characters including the newline character '\n'.
Example in pseudo code :
t = "foo\nbar\nnil"
r = "foo.*nil"
r.match(t, 's') => false;
If the dotall 's' flag was supported then the regular expression would match.
There is a workaround for this : Instead of using the dot character in the regex we can use the [\s\S] pattern :
r = "foo[\s\S]*nil"
r.match(t, 's') => true;
Since the documentation mention that MongoDB supports PCRE I consider this as a bug, none critical since a workaround exists.
One could consider this as a feature request, I have no issue with that
The bug is trivial to fix. See attached patch below. However the patch does not solve potential issues with other drivers such the javascript shell.
Indeed Javascript does not support the 's' flag ...
Since this is my first contact with the MongoDb community I would like to take the opportunity to thank you all for the amazing work around MongoDb
Cheers,
CH