On 30-Jul-2014 12:53 +0200, Bram Moolenaar wrote:

> Tim Brosnan wrote:
> 
>> I initially send a version of this message through the google groups 
>> interface, but it seems to have disappeared. Apologies if there is 
>> duplication.
>>
>> When going through some regex examples from 
>> VimRegexTutor(https://github.com/dahu/VimRegexTutor) I found that one of 
>> the examples did not match the provided text when run in 7.4.383. Here 
>> is the regex and the sample text:
>>
>>   *30* : Find Text between HTML tags >
>>
>>       /\%(<\1>\)\@<=.*\%(<\/\(\w\+\)>\)\@=
>>
>>       OR
>>
>>       /\v%(\<\1\>)@<=.*%(\<\/(\w+)\>)@=
>> <
>>       <level>Can I play, daddy?</level>
>>
>> Neither of the provided regexs would watch the sample text (it should 
>> match the text between html tags). However, when I tried 7.1.42 (only 
>> other version at hand) I found that the text between tags was matched 
>> correctly. Both versions were fun as -u NONE and "set nocompatible" to 
>> try to rule out option or plugin clashes.
>>
>> Is this is a bug or has regex behaviour changed between 7.1.42 and 7.4.383?
> 
> I don't think the pattern is supposed to work.  The backreference is
> before the capturing group.

Well, it does work in the old engine.

> It's a suprise it works at all.  Probably because in the old regex
> engine the "\@<=" part is used only after finding a match for the
> rest.
> 
> It's a very inefficient pattern too, better use:
> 
>        /<\(\w\+\).\{-}>\zs.*\ze<\/\1>

You cannot always use \zs in place of \@<= (for example, with :syntax
match, or when already using a \zs elsewhere in the pattern).

Just changing the example in the help isn't going to solve the problem
of backwards compatibility. I think the new engine either has to support
it, or detect that special situation and then dynamically switch to the
old engine (like \%#=1 does).

-- regards, ingo

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Raspunde prin e-mail lui