You are viewing a plain text version of this content. The canonical link for it is here.
Posted to oro-user@jakarta.apache.org by "Daniel F. Savarese" <df...@savarese.org> on 2004/02/11 12:12:53 UTC

Re: Stack Overflow Problmen - reformat regular expression

>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



---------------------------------------------------------------------
To unsubscribe, e-mail: oro-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: oro-user-help@jakarta.apache.org


Re: Stack Overflow Problmen - reformat regular expression

Posted by "Ulla (Ulrike) Schat" <ul...@trema.com>.
Hello again,

I am terribly sorry but I didn't check the result of the new regular 
expression well enough. I was so happy that it solved the Stack Overflow 
Error that I just believed it would be fine. :-(

But now I saw that from the ending of the input String "...-}", it 
leaves the "-" which should not be included in the result.

There is always something before the "-}" so it is ok to use + and not 
*. But also with the old expression, using + instead of *, 
"{(\\d+):(([^}](?!-}))+)", I get the StackOverflowError if the input is 
long.


Thanks again for any help or suggestions!
Ulla



Ulla (Ulrike) Schat wrote:

> Hi,
> 
>> 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.
> 
> 
> I just re-tested with 2.0.8. and I also have the same problem with my 
> original test program.
> 
> 
>> What Java runtime are you using and on what OS?  
> 
> 
> I am using java verson 1.4.2_03 on Windows 2000.
> 
> However, rewriting the old expression "{(\\d+):([^}]*)(?!-})"
> to what you suggested "{(\\d+):([^}]+)(?!-})" did the trick!
> Plus it seems quite fast!
> 
> 
> Thanks a lot for your help!
> Ulla
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: oro-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: oro-user-help@jakarta.apache.org


Re: Stack Overflow Problmen - reformat regular expression

Posted by "Ulla (Ulrike) Schat" <ul...@trema.com>.
Hi,

> 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.

I just re-tested with 2.0.8. and I also have the same problem with my 
original test program.


> What Java runtime are you using and on what OS?  

I am using java verson 1.4.2_03 on Windows 2000.

However, rewriting the old expression "{(\\d+):([^}]*)(?!-})"
to what you suggested "{(\\d+):([^}]+)(?!-})" did the trick!
Plus it seems quite fast!


Thanks a lot for your help!
Ulla

---------------------------------------------------------------------
To unsubscribe, e-mail: oro-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: oro-user-help@jakarta.apache.org