From: "k0kubun (Takashi Kokubun) via ruby-core" Date: 2026-11-16T17:42:35+00:00 Subject: [ruby-core:127515] [Ruby Bug#22494] Regexp search misses a match when an assertion precedes a leading .* Issue #22494 has been updated by k0kubun (Takashi Kokubun). Backport changed from 3.3: REQUIRED, 3.4: REQUIRED, 4.0: REQUIRED to 3.3: REQUIRED, 3.4: REQUIRED, 4.0: DONE ruby_4_0 commit:85e6cd39a35f116d6c618309286594fbb5b40e37 merged revision(s) commit:dbfe6bac2285ea61a76a2dec970cf859f5a8fef4. ---------------------------------------- Bug #22494: Regexp search misses a match when an assertion precedes a leading .* https://bugs.ruby-lang.org/issues/22494#change-119983 * Author: mame (Yusuke Endoh) * Status: Closed * Backport: 3.3: REQUIRED, 3.4: REQUIRED, 4.0: DONE ---------------------------------------- When a regexp starts with an assertion (`^`, `\b`, `(?=...)`, `(?!...)`) followed by `.*`, the search only tries the start position and misses later matches. ```ruby "aab".index(/(?!a).*b/m) #=> nil (expected: 2) "ab\ncb".index(/^.*b/m, 1) #=> nil (expected: 3) "aaaa bx".index(/\b.*x/, 1) #=> nil (expected: 4) ``` @make_now_just found this and wrote the fix. -- https://bugs.ruby-lang.org/ ______________________________________________ ruby-core mailing list -- ruby-core@ml.ruby-lang.org To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org ruby-core info -- https://ml.ruby-lang.org/mailman3/lists/ruby-core.ml.ruby-lang.org/