Issue #22491 has been updated by mame (Yusuke Endoh). https://github.com/ruby/ruby/pull/19641 ---------------------------------------- Bug #22491: The number of captures may change depending on the encoding of the target string https://bugs.ruby-lang.org/issues/22491#change-119717 * 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/