opensubscriber
   Find in this group all groups
 
Unknown more information…

r : regexp-user@jakarta.apache.org 29 December 2005 • 3:23AM -0500

RE: Stackoverflow error
by Rodgers, Kevin

REPLY TO AUTHOR
 
REPLY TO GROUP




patils@lake... writes:
> I have to parse the following strings
>
> -DATA datavalue
> +DATA datavalue
>
> I am using the following regular expression
> ^{?:\+\\-)DATA\s*(.*)$
   ^
   | should be (

> This gives stack overflow if the string is more than 3.6k
>
> Do you have any recommendations to resolve this issue.

I think you could simplify ^(?:\+\\-) to just [-+]

But more importantly, I think you can get rid of some potential
backtracking decision points if you know there's exactly a single
whitespace character between DATA and datavalue: DATA\s(.*)$

--
Kevin





Bookmark with:

Delicious   Digg   reddit   Facebook   StumbleUpon

Related Messages

opensubscriber is not affiliated with the authors of this message nor responsible for its content.