Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-2943

dotall flag 's' from PCRE is not supported

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Trivial - P5 Trivial - P5
    • 1.9.0
    • Affects Version/s: 1.8.0, 1.8.1
    • Component/s: Querying
    • Environment:
      All
    • Fully Compatible
    • ALL

      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

        1. dotall.patch
          0.4 kB
          Charles-Henri d'Adhémar

            Assignee:
            mathias@mongodb.com Mathias Stearn
            Reporter:
            cdadhemar Charles-Henri d'Adhémar
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: