From: "mame (Yusuke Endoh) via ruby-core" Date: 2026-11-02T11:56:02+00:00 Subject: [ruby-core:127292] [Ruby Bug#22491] The number of captures may change depending on the encoding of the target string Issue #22491 has been reported by mame (Yusuke Endoh). ---------------------------------------- Bug #22491: The number of captures may change depending on the encoding of the target string https://bugs.ruby-lang.org/issues/22491 * Author: mame (Yusuke Endoh) * Status: Open * Backport: 3.3: UNKNOWN, 3.4: UNKNOWN, 4.0: UNKNOWN ---------------------------------------- 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/