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

dotall flag 's' from PCRE is not supported

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Trivial - P5
    • Resolution: Fixed
    • Affects Version/s: 1.8.0, 1.8.1
    • Fix Version/s: 1.9.0
    • Component/s: Querying
    • Labels:
    • Environment:
      All
    • Backwards Compatibility:
      Fully Compatible
    • Operating System:
      ALL

      Description

      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

        Attachments

          Activity

            People

            Assignee:
            redbeard0531 Mathias Stearn
            Reporter:
            cdadhemar Charles-Henri d'Adhémar
            Participants:
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: