Issue #8023 has been updated by pietzcker (Tim Pietzcker).


Some more observations:

Adding an end-of-line anchor doesn't change anything:

irb(main):016:0> "foo" =~ /(?<=fo).*$/m
=> nil

But together with a lazy quantifier, it "works":

irb(main):017:0> "foo" =~ /(?<=fo).*?$/m
=> 2
----------------------------------------
Bug #8023: Lookbehind assertion fails with /m mode enabled
https://bugs.ruby-lang.org/issues/8023#change-37317

Author: pietzcker (Tim Pietzcker)
Status: Open
Priority: Normal
Assignee: 
Category: 
Target version: 
ruby -v: ruby 2.0.0p0 (2013-02-24) [x64-mingw32]


Lookbehind assertions fail if they are longer than one character, and if dotall mode is set.

irb(main):001:0> "foo" =~ /(?<=f).*/m
=> 1
irb(main):002:0> "foo" =~ /(?<=fo).*/m
=> nil

The latter should have matched the "o". This only seems to happen with dotall mode turned on (dot matches newline); without it, everything is OK:

irb(main):003:0> "foo" =~ /(?<=f).*/
=> 1
irb(main):004:0> "foo" =~ /(?<=fo).*/
=> 2


-- 
http://bugs.ruby-lang.org/