From: "nagachika (Tomoyuki Chikanaga) via ruby-core" Date: 2026-11-08T05:47:48+00:00 Subject: [ruby-core:127356] [Ruby Bug#22491] The number of captures may change depending on the encoding of the target string Issue #22491 has been updated by nagachika (Tomoyuki Chikanaga). Backport changed from 3.3: REQUIRED, 3.4: REQUIRED, 4.0: REQUIRED to 3.3: REQUIRED, 3.4: DONE, 4.0: REQUIRED ruby_3_4 commit:1fe5db3586edf57ff67728c07a7bfd27b9aad13b merged revision(s) commit:b4e5cb26164848f4d5b775a624533c4583a73264. ---------------------------------------- Bug #22491: The number of captures may change depending on the encoding of the target string https://bugs.ruby-lang.org/issues/22491#change-119789 * Author: mame (Yusuke Endoh) * Status: Closed * Backport: 3.3: REQUIRED, 3.4: DONE, 4.0: REQUIRED ---------------------------------------- The number of captures of a Regexp may change depending on the encoding of the target string. ```ruby E = "stateless-ISO-2022-JP" a = "���".encode("EUC-JP").encode(E) re = Regexp.new("()()#".encode(E) + a + "()()".encode(E), Regexp::EXTENDED) p re.match("ab".encode(E)).size #=> 3 p re.match(a).size #=> 5 (expected: 3) ``` -- 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/