Project

General

Profile

Actions

Bug #9902

closed

Regexp#[] ignores after NUL byte in named capture index

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

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

Description

Regexp#[]に"\0"を含む文字列やシンボルを指定したとき、それ以降が無視されます。

$ ruby -w -e 'p(/(?<a>.*)/.match("foo")["a\0foo"])'
"foo"

$ ruby -w -e 'p Regexp.new("(?<foo\0bar>.*?)").match("xxx")["foo\0bar"]'
-e:1:in `[]': undefined group name reference: foo (IndexError)
	from -e:1:in `<main>'
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0