[ruby-core:127297] [Ruby Bug#22494] Regexp search misses a match when an assertion precedes a leading .*
Issue #22494 has been reported by mame (Yusuke Endoh). ---------------------------------------- Bug #22494: Regexp search misses a match when an assertion precedes a leading .* https://bugs.ruby-lang.org/issues/22494 * Author: mame (Yusuke Endoh) * Status: Open * Backport: 3.3: UNKNOWN, 3.4: UNKNOWN, 4.0: UNKNOWN ---------------------------------------- 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/
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/
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/
Issue #22494 has been updated by nagachika (Tomoyuki Chikanaga). Backport changed from 3.3: REQUIRED, 3.4: REQUIRED, 4.0: DONE to 3.3: REQUIRED, 3.4: DONE, 4.0: DONE ruby_3_4 commit:9ffd2fa933f83171056bc9871908fe95a7efa2ca 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-120035 * Author: mame (Yusuke Endoh) * Status: Closed * Backport: 3.3: REQUIRED, 3.4: DONE, 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/
participants (3)
-
k0kubun (Takashi Kokubun) -
mame (Yusuke Endoh) -
nagachika (Tomoyuki Chikanaga)