Project

General

Profile

Actions

Bug #9903

closed

Regexp#[] doesn't consider capture name encoding

Added by nobu (Nobuyoshi Nakada) over 10 years ago. Updated about 10 years ago.

Status:
Closed
Assignee:
-
Target version:
-
ruby -v:
r46343
[ruby-dev:48278]

Description

Regexp#[]が引数の文字列やシンボルを考慮していません。

key = "\xb1\xb2".force_encoding(Encoding::EUC_JP)
m = /(?<#{key}>.*)/.match("xxx")
p m[key.dup.force_encoding(Encoding::Shift_JIS)]
# => "xxx"
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0