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
opensubscriber is not affiliated with the authors of this message nor responsible for its content.