[ruby-trunk - Bug #8138][Open] rpartition(regexp) for multibyte string

Issue #8138 has been reported by no6v (Nobuhiro IMAI).


Bug #8138: rpartition(regexp) for multibyte string
https://bugs.ruby-lang.org/issues/8138

Author: no6v (Nobuhiro IMAI)
Status: Open
Priority: Normal
Assignee:
Category: core
Target version:
ruby -v: ruby 2.1.0dev (2013-03-21 trunk 39858) [x86_64-linux]

=begin
以下のように、String#rpartition に正規表現を渡したとき、マルチバイト文字列だと挙動がおかしいようです。

encoding: UTF-8

[email protected]”.partition("@") # => [“user”, “@”, “domain”]
[email protected]”.partition(/@/) # => [“user”, “@”, “domain”]
[email protected]”.rpartition("@") # => [“user”, “@”, “domain”]
[email protected]”.rpartition(/@/) # => [“user”, “@”, “domain”]
“ユーザ@ドメイン”.partition("@") # => [“ユーザ”, “@”, “ドメイン”]
“ユーザ@ドメイン”.partition(/@/) # => [“ユーザ”, “@”, “ドメイン”]
“ユーザ@ドメイン”.rpartition("@") # => [“ユーザ”, “@”, “ドメイン”]
“ユーザ@ドメイン”.rpartition(/@/) # => [“ユーザ@ドメイン”, “@”, nil]
=end

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs