Re: Stack Overflow Problmen - reformat regular expression

"Daniel F. Savarese" <[email protected]> Wed, 11 Feb 2004 06:12:53 -0500
Newsgroups gmane.comp.jakarta.oro.user
Message-ID <[email protected]>
>I am using Oro 2.0.1. I get a StackOverflowError and it looks to me like 
>the problem that was described in the Thread "Stack Overflow Problem" 
...
>I tried several changes for the regular expressions but I always got the 
>following StackOverflowError if the input String is quite long (see 
>attached test program):

I ran your test program with no problems using jakarta-oro 2.0.8 and
JDK's 1.2, 1.3, and 1.4 for Linux.  I then downloaded the 2.0.1
distribution and tried the same thing with that with the same result.
What Java runtime are you using and on what OS?  You have a few
of options if the problem can't be reproduced.  One is to increase
your stack size.  Another is to try a different JVM or fiddle with
options like JIT optimizations.  Yet another is to rewrite the
regular expression to the more compact and efficient:
  String regexp_pattern = "{(\\d+):([^}]*)(?!-})";
Basically, you never want to use the form ((foo)*) when (foo*) will do.
I'm not entirely sure of your requirements, but if the input will
never be empty (always at least be a "-" before ending "}"), then
+ instead of * is preferable:
  String regexp_pattern = "{(\\d+):([^}]+)(?!-})";

Hope that helps.

daniel