From: "mame (Yusuke Endoh) via ruby-core" Date: 2026-11-02T13:25:03+00:00 Subject: [ruby-core:127298] [Ruby Bug#22494] Regexp search misses a match when an assertion precedes a leading .* Issue #22494 has been updated by mame (Yusuke Endoh). Backport changed from 3.3: UNKNOWN, 3.4: UNKNOWN, 4.0: UNKNOWN to 3.3: REQUIRED, 3.4: REQUIRED, 4.0: REQUIRED https://github.com/ruby/ruby/pull/19645 ---------------------------------------- Bug #22494: Regexp search misses a match when an assertion precedes a leading .* https://bugs.ruby-lang.org/issues/22494#change-119723 * Author: mame (Yusuke Endoh) * Status: Open * Backport: 3.3: REQUIRED, 3.4: REQUIRED, 4.0: REQUIRED ---------------------------------------- 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/