[ruby-trunk - Bug #8856][Open] gsub doesn't work properly with \K

Issue #8856 has been reported by k_takata (Ken Takata).


Bug #8856: gsub doesn’t work properly with \K
https://bugs.ruby-lang.org/issues/8856

Author: k_takata (Ken Takata)
Status: Open
Priority: Normal
Assignee:
Category: regexp
Target version:
ruby -v: 2.0.0p247
Backport: 1.9.3: UNKNOWN, 2.0.0: UNKNOWN

Regexp#gsub で \K を使うと、正しく動作しないようです。
Regexp#sub は問題ありません。

http://rubyist.g.hatena.ne.jp/n2s/20130714/p1 より、

% irb-ruby-2.0.0-p247
2.0.0p247 :001 > a=“foobarbazquux/foobarbazquux”
=> “foobarbazquux/foobarbazquux”
2.0.0p247 :002 > a.sub(/foo\Kbar/, “”)
=> “foobazquux/foobarbazquux”
2.0.0p247 :003 > a.gsub(/foo\Kbar/, “”)
=> “bazquux/bazquux”

Issue #8856 has been updated by nobu (Nobuyoshi N.).

Backport changed from 1.9.3: UNKNOWN, 2.0.0: UNKNOWN to 1.9.3: DONTNEED,
2.0.0: REQUIRED


Bug #8856: gsub doesn’t work properly with \K
https://bugs.ruby-lang.org/issues/8856#change-41591

Author: k_takata (Ken Takata)
Status: Open
Priority: Normal
Assignee:
Category: regexp
Target version:
ruby -v: 2.0.0p247
Backport: 1.9.3: DONTNEED, 2.0.0: REQUIRED

Regexp#gsub で \K を使うと、正しく動作しないようです。
Regexp#sub は問題ありません。

http://rubyist.g.hatena.ne.jp/n2s/20130714/p1 より、

% irb-ruby-2.0.0-p247
2.0.0p247 :001 > a=“foobarbazquux/foobarbazquux”
=> “foobarbazquux/foobarbazquux”
2.0.0p247 :002 > a.sub(/foo\Kbar/, “”)
=> “foobazquux/foobarbazquux”
2.0.0p247 :003 > a.gsub(/foo\Kbar/, “”)
=> “bazquux/bazquux”

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