You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've tried to match a BEGIN...END block only if there's no MIDDLE inside; like the second block in the following example:
BEGIN
some
MIDDLE
stuff
END
BEGIN
other
stuff
END
I came up with the following regular expression, using the whole pattern multi (\@>) to avoid backtracking and a non-greedy multi-line atom (\_.\{-}) to match just a single block.
In Vim version 8.1.553 (huge version with GTK2 GUI, on Ubuntu 16.04.5 LTS x64), this only matches with the old engine ('regexpengine' set to 1); it does not match with the new, NFA-based one. I think this is a bug; the behavior should not differ.
Investigations
The problem is not triggered when the entire match is on a single line. The following joins the text into one line, and this gives 1 as expected:
vim --clean \
-c 'let @x = "BEGIN some MIDDLE stuff END BEGIN other stuff END "' \
-c 'silent put! x' \
-c 'echomsg search("\\%#=2\\%(BEGIN\\_.\\{-}\\%(MIDDLE\\|END\\)\\)\\@>\\%(END\\)\\@<=")'
The problem is only triggered when doing text searches (with /, or :echo search(), but not with =~ or matchstr(). The following gives old:1 new:1:
I tried to write an automated test for it, but I only found coverage of old-vs-new regexp engines in (old-style) test44.in / test99.in, and this multi-line example here doesn't seem to fit in with that very well. I guess you'll be able to quickly build a new-style test from the code above.
The text was updated successfully, but these errors were encountered:
Example
I've tried to match a BEGIN...END block only if there's no MIDDLE inside; like the second block in the following example:
I came up with the following regular expression, using the whole pattern multi (
\@>
) to avoid backtracking and a non-greedy multi-line atom (\_.\{-}
) to match just a single block.In Vim version 8.1.553 (huge version with GTK2 GUI, on Ubuntu 16.04.5 LTS x64), this only matches with the old engine (
'regexpengine'
set to1
); it does not match with the new, NFA-based one. I think this is a bug; the behavior should not differ.Investigations
The problem is not triggered when the entire match is on a single line. The following joins the text into one line, and this gives
1
as expected:The problem is only triggered when doing text searches (with
/
, or:echo search()
, but not with=~
ormatchstr()
. The following givesold:1 new:1
:How to reproduce
The following two invocations use the different engines; the first correctly gives
6
, the second wrongly0
:I tried to write an automated test for it, but I only found coverage of old-vs-new regexp engines in (old-style)
test44.in
/test99.in
, and this multi-line example here doesn't seem to fit in with that very well. I guess you'll be able to quickly build a new-style test from the code above.The text was updated successfully, but these errors were encountered: