[quoted text, click to view] Jesse Houwing wrote:
> Hello John,
>
>> I am trying to do a pretty simple pattern match using regex.
>>
>> The pattern is ^(?:(?<Item>.*?)@:@)*$.
>>
<...>
>
> ^(?:(?<Item>.*?)@:@)*$
>
> I'd giess that the problem lies in the last *, but I'm unsure why it
> would hang the parser. I've seen these kinds of problems before where a
> lot of backtracking is possible.
>
> a better pattern would be: ^(?<item>.*)@:@$
Hi Jesse, thanks for the reply.
I need the Group(Named Group())repetition because I am trying to match
a@:@b@:@c@:@d@:@e@:@f@:@g@:@
1@:@2@:@3@:@4@:@
etc.. (a..b..c are not the real values, it is actually more characters,
but the effect should be the same.
[quoted text, click to view] >
> The extra ? after the first .* isn't really needed, unless there are
> more than one @:@ signs in your text at the end of a line (which I
> doubt). But as you've not sent us the text you're trying to extract
> your pattern from I'd have to guess that.
>
Hmm, it is necessary in the regulator, and should be by my
understanding, to make it non-greedy.
[quoted text, click to view] > Another pattern that would probably work would be:
>
> ^(?<item>[^@]*)@:@$ but in there I assume that @ does not precede the
> @:@ at all.
>
> I hope this helps. If not, please add some sample input.
>
See above.
[quoted text, click to view] > Another possible problem might be that your input is simply too large.
> The engine isn't very good at reading multiple megabytes of text at
> once. As you're looking at the lines one by one, you could use that to
> your advantage and load a couple of lines, try to match and load the
> next couple of lines. A StringReader would be ideal for that purpose.
>
Yep, I thought of that too, I have tried it with a single line, half a
line, and a single possible match, all hang the parser.
A funny thing though, originally when I was experimenting with less than
a line, it would work for a bit and the stop at a certain point, now it
wont even match the 1 candidate.
TIA