Re: [pcre-dev] Question about .*

Top Page
Delete this message
Author: Zoltán Herczeg
Date:  
To: Giuseppe D'Angelo, Vicente Ferrari
CC: pcre-dev@exim.org
Subject: Re: [pcre-dev] Question about .*
I have two comments:

The .* matches to an emtpy string, so it can match to the position of "\r" in a "\r" string. The length of the match is 0, so it does not match to the "\r" itself.

The PCRE2_DOTALL option allows dot to match to a newline.

Regards,
Zoltan

-------- Eredeti levél --------
Feladó: Giuseppe D'Angelo via Pcre-dev < pcre-dev@??? (Link -> mailto:pcre-dev@exim.org) >
Dátum: 2021 május 11 00:20:45
Tárgy: Re: [pcre-dev] Question about .*
Címzett: Vicente Ferrari < vikhenzo@??? (Link -> mailto:vikhenzo@gmail.com) >
Hi,
On Mon, 10 May 2021 at 21:42, Vicente Ferrari via Pcre-dev
<pcre-dev@???> wrote:
>
> Hello, sorry to bother with a basic question.
>
> I'm wondering about the expected result when matching ".*" against a string
> with new lines.
> I compiled PCRE2 with the ANYCRLF option, expecting that the pcre2demo.c
> program would
> basically completely ignore those newlines. Instead, I get matches of
> length 0 at the index of the
> \r, no matches where \n is and then the next correct match starts at the
> correct offset, taking into account the length 2 of the newlines.
>
> I was expecting newlines to produce no matches at all, am I doing something
> wrong?

It's hard to say without any testdata; could you please share some
examples of the patterns that you're using, and the corresponding
subject strings that seem to match at unexpected places?
HTH,
--
Giuseppe D'Angelo
--
## List details at https://lists.exim.org/mailman/listinfo/pcre-dev