Re: [pcre-dev] Dollar problem

Page principale
Supprimer ce message
Auteur: MX
Date:  
À: pcre-dev
Sujet: Re: [pcre-dev] Dollar problem
Philip Hazel <ph10@???> писал(а) в своём письме Sun, 22 Aug
2010 21:10:38 +0400:

> On Fri, 20 Aug 2010, ND wrote:
>
>> Subject: aa<CR><LF>b
>> Pattern: a$
>> Match: RegEx error - PCRE_ERROR_NOMATCH
>>
>> If
>> Pattern: aa$
>> then
>> Match: aa
>>
>> Why 'PCRE_ERROR_NOMATCH' in first example?
>
> When I test, I get NOMATCH in the second example as well.
>
> You don't say what options you used, if any. You need
>
> (1) PCRE_MULTILINE to tell PCRE that the subject is more than one line.
> (2) PCRE_NEWLINE_CRLF or PCRE_ANYCRLF or PCRE_ANY so that <CR><LF> is
> interpreted as a newline sequence. Testing with pcretest shows that this
> works:
>
> PCRE version 8.10 2010-06-25
>
> /a$/m<crlf>
> aa\r\nb
> 0: a
> It also works if the pattern is aa$.
>
> This is what the documentation says:
>
>        PCRE_MULTILINE
>     By  default,  PCRE  treats the subject string as consisting of a  
> single
>      line of characters (even if it actually contains newlines). The   
> "start
>      of  line"  metacharacter  (^)  matches only at the start of the  
> string,
>      while the "end of line" metacharacter ($) matches only at  the   
> end  of
>      the string, or before a terminating newline (unless  
> PCRE_DOLLAR_ENDONLY
>      is set). This is the same as Perl.
>     When PCRE_MULTILINE it is set, the "start of line" and  "end  of   
> line"
>      constructs  match  immediately following or immediately before  
> internal
>      newlines in the subject string, respectively, as well as  at  the   
> very
>      start  and  end.

>
>
>
>
> Philip
>



I have a dialog with Sheri and discover that it is not original PCRE
fault, but error of PCRE-wrapper that I use.

Thanx.