Re: [pcre-dev] probably basic pcre question

Page principale
Supprimer ce message
Auteur: Philip Hazel
Date:  
À: jamal
CC: pcre-dev
Sujet: Re: [pcre-dev] probably basic pcre question
> The manual says to simulate /s i need to turn on PCRE_DOTALL when
> i compile a pattern. Thats the only thing i have added to the options
> of pcre_compile("(^: (.*?)(\r\n\r\n))"); i didnt touch pcre_exec().
> It doesnt work. Heres a sample incoming stream (shown above in
> pcretest):
>
> ---
> E: e1\r\nA: a1\r\nB: b1\r\n\r\nCRAP: c1
> ----
>
> What i end up matching in the ovectors by number.....
>
> ------
> 0: E: e1\x0d\x0aA: a1\x0d\x0aB: b1\x0d\x0a\x0d\x0aCRAP: c1
> 1: E: e1\x0d\x0aA: a1\x0d\x0aB: b1\x0d\x0a\x0d\x0aCRAP: c1
> 2: E: e1\x0d\x0aA: a1\x0d\x0aB: b1\x0d\x0a\x0d\x0aCRAP: c1
> 3: B: b1\x0d\x0a\x0d\x0aCRAP: c1
> ---------


That doesn't make any sense. Your pattern "(^: (.*?)(\r\n\r\n))" starts
matching : at the start of a line; your ovector 0 doesn't. Perhaps you
copied that wrong. Is it really meant to be "(^E: (.*?)(\r\n\r\n))"? If
so, there's still something wrong, because parentheses number 3 contain
only \r\n\r\n and yet your ovector buffer 3 contains other stuff.
Equally, I can't see why #2 should contain the E:. Perhaps you should
post your test program so we can see what the C looks like.

Note also that pcre_compile("\r\n"...) isn't the same as pcretest with
/\r\n/ but that shouldn't actually matter.

Philip

--
Philip Hazel