[SERVER-3556] Using Lookaround with Regex Created: 09/Aug/11 Updated: 30/Mar/12 Resolved: 31/Oct/11 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | JavaScript |
| Affects Version/s: | 1.8.2 |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Minor - P4 |
| Reporter: | POITTEVIN Raphael | Assignee: | Antoine Girbal |
| Resolution: | Done | Votes: | 0 |
| Labels: | eval, java, regex | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Environment: |
uname -a : |
||
| Operating System: | Linux |
| Participants: |
| Description |
|
Hello, I'm using MongoDb in a GWT(2.3) project (with Morphia 0.99). 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). So my java code is something like : >)"); Nb : In my Pattern.compile(), I use {0,10}, as Java doesn't support * in regex's look-around. Nb2 : I made some little test without all javaDrivers and db.eval(), ); > db.Test.find().forEach(function ); 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. |
| Comments |
| Comment by Antoine Girbal [ 31/Oct/11 ] |
|
raphael, |
| Comment by Antoine Girbal [ 29/Sep/11 ] |
|
The lookbehind feature may not be well supported by the different libraries. What exactly are you trying to match? |
| Comment by POITTEVIN Raphael [ 09/Aug/11 ] |
|
In fact, I'm using regex in a larger javascript function. I've been doing some test on my computer, here are the results: Nb: For all my tests, I created a collection 'Test' : ); ); Test #1 >)"); This returns me >)" , "$options" : ""}}, numIterated=0 So it's working pretty well (at least, there is no error). But I thought there should be some results. This regex is supposed to match the word 'value' when there is no '<' without '>' before, and no '>' without '<' after (ie : this regex match 'value' when it's not in a markup). I also tried to lunch a find() directly in mongo : >)" , "$options" : ""}}); I asked myself if Lookaround where allowed in mongo. Therefore I lunched the following line: This is working quite well. It's when I try to add the [^<]* that problems occurs. Any Ideas? Is my regex clumsy? Am I doing something wrong? Test #2 In order to reproduce the error, I simplified my function to the minimum. First of all, I stored that simple function in my mongo database: }); Then, I just tried to lunch a db.eval() on this function. So my java code looks like that : >)"); When I execute those lines, I get the following debug: >) ) returned { "assertion" : "assertion scripting/engine_spidermonkey.cpp:634" , "errmsg" : "db assertion failure" , "ok" : 0.0}
If I call db.eval() directly in mongo, it doesn't throws any error : >)', '$options' : ''});"); But the replacement isn't done. Hope this help you understand what is this problem about. POITTEVIN Raphael |
| Comment by Eliot Horowitz (Inactive) [ 09/Aug/11 ] |
|
If all you're doing is regex, then you shouldn't use javascript at all. You would just do Pattern regex = Pattern.compile("(?<!<[^>] {0,10})foo(?>![^<]{0,10}>)"); Can you try that? |