RE: Stackoverflow error
"Rodgers, Kevin" <[email protected]> Wed, 28 Dec 2005 12:23:22 -0700
| Newsgroups | gmane.comp.jakarta.regexp.user |
|---|---|
| Message-ID | <C2CEBB9E4C66DF44809F06ABD336311DCB6F98@s255478hz1ew06.hosted.internal.corp> |
------_=_NextPart_001_01C60BE4.BD53134A Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable [email protected] writes: > I have to parse the following strings=20 >=20 > -DATA datavalue > +DATA datavalue >=20 > I am using the following regular expression > ^{?:\+\\-)DATA\s*(.*)$ ^ | should be ( > This gives stack overflow if the string is more than 3.6k >=20 > 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(.*)$ --=20 Kevin ------_=_NextPart_001_01C60BE4.BD53134A Content-Type: text/plain; charset=us-ascii --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected] ------_=_NextPart_001_01C60BE4.BD53134A--