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

Using Lookaround with Regex



    • Bug
    • Status: Closed
    • Minor - P4
    • Resolution: Works as Designed
    • 1.8.2
    • None
    • JavaScript
    • uname -a :
      Linux 2.6.38-10-generic-pae #46-Ubuntu SMP Tue Jun 28 16:54:49 UTC 2011 i686 i686 i386 GNU/Linux
    • Linux



      I'm using MongoDb in a GWT(2.3) project (with Morphia 0.99).
      My GWT project is calling a mongoside function (stored in db.system.js) thanks to DB.eval(). One of my function's argument is a Regex. When i'm using a Regex like "\bFOO\b", it's working fine, but when my regexp become like "(?<!<[^>])\bFOO\b(?>![^<]>)" then, i get this error:

      Erreur serveur: eval failed:

      { "assertion" : "assertion scripting/engine_spidermonkey.cpp:634" , "errmsg" : "db assertion failure" , "ok" : 0.0}

      com.mongodb.MongoException: eval failed:

      { "assertion" : "assertion scripting/engine_spidermonkey.cpp:634" , "errmsg" : "db assertion failure" , "ok" : 0.0}

      at com.mongodb.DB.eval(DB.java:223)

      This error occurs in my GWT project (so, in jetty, as it is on the server side of my GWT project).
      The regex i'm passing as an argument to my db.eval() is compiled by Java.

      So my java code is something like :
      String exec = "return serverSideFunction(args[0]);";
      Pattern regex = Pattern.compile("(?<!<[^>]


      Object result = db.eval(exec, regex);

      Nb : In my Pattern.compile(), I use


      , as Java doesn't support * in regex's look-around.

      Nb2 : I made some little test without all javaDrivers and db.eval(),
      this looks like
      > db.Test.save(

      {'key':'<mark key="value">value</mark>'}

      > db.Test.find();

      { "_id" : ObjectId("4e40d9c750d109bc7de98858"), "key" : "<mark key=\"value\">value</mark>" }

      > db.Test.find().forEach(function

      {x.key.replace(new RegExp('(?<!<[^>]*)value(?>![^<]*>)',''),'VALUE'); db.Test.save(x);}

      Tue Aug 9 09:04:47 SyntaxError: invalid quantifier ?<!<[^>])value(?>![^<]>) (shell):1

      The error I get is not the same, but unless i'm doing it wrong, lookaround's features aren't really working in Mongo, aren't them?

      This is my first bug reporting ever, so please tell me if I'm doing it wrong.
      I stay at your disposal if you need any further information.




            antoine Antoine Girbal
            piroxxi POITTEVIN Raphael
            0 Vote for this issue
            3 Start watching this issue