OK, so I was happily just using the oromatcher Perl5Compiler() routines to handle python style regular expressions in my java code.  Basically the regular expressions get passed from the jython script through to a java function of mine and I wanted to handle them in a python compatible way.  It turns out that I wasn't completely correct.


I got code that actually worked pretty well until I started passing expressions such as this to it:


"(source filename|Name of).*\?(?i)"


The gotcha is the (?i) bit at the end, this generates a mismatched parenthesis error.


Now after a lot of delving I've discovered that jython actually uses a completely different regular expression library - the one in the sre module.  My question is, since this is all python code, is there any way that I can just call out to this from java? It appears to me that by moving over to a python implementation here I can't use the same stuff - so far I've found one incompatibility between the two implementations, and I'm concerned that I'll run into others.


Am I stuck with pre-processing the regular expressions and handling the (?i) construct myself - I can't believe that's all that there is to it.


Any other alternatives?


As an aside, why the switch to sre?  Faster?  Better Python compatibility?


Thanks - Guy