RE: Stackoverflow error

[email protected] Wed, 28 Dec 2005 14:40:18 -0500
Newsgroups gmane.comp.jakarta.regexp.user
Message-ID <OFCEE35822.B488CE1E-ON852570E5.006BD196-852570E5.006C0FBE@lakeviewtech.com>
--=_alternative 006C0FAB852570E5_=
Content-Type: text/plain; charset="US-ASCII"

Hi Kevin

Using [-+]DATA\s(.*)$ fails to parse

If I use .* as the regular expression it still gives stackoverflow 
message.


Sujata Patil,




"Rodgers, Kevin" <[email protected]> 
12/28/2005 02:23 PM
Please respond to
"Regexp Users List" <[email protected]>


To
"Regexp Users List" <[email protected]>
cc

Subject
RE: Stackoverflow error






[email protected] 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




---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

--=_alternative 006C0FAB852570E5_=--