From: kasumi@... Date: 2020-08-11T09:59:35+00:00 Subject: [ruby-core:99553] [Ruby master Bug#17113] /\K/ in separator for String#split behaves differently than /(?<=)/ Issue #17113 has been reported by hanazuki (Kasumi Hanazuki). ---------------------------------------- Bug #17113: /\K/ in separator for String#split behaves differently than /(?<=)/ https://bugs.ruby-lang.org/issues/17113 * Author: hanazuki (Kasumi Hanazuki) * Status: Open * Priority: Normal * ruby -v: ruby 2.8.0dev (2020-08-11T07:51:07Z master 5af983af4f) [x86_64-linux] * Backport: 2.5: UNKNOWN, 2.6: UNKNOWN, 2.7: UNKNOWN ---------------------------------------- When a String is `#split`ted with a pattern containing /\K/ (lookbehind) operator, the portion that matches the lookbehind pattern will not appear in the result. ```ruby "abcd".split(/b\Kc/) # => ["a", "d"] "abcd".split(/(?<=b)c/) # => ["ab", "d"] -- expected result ``` In this example, since `/b\Kc/` matches `"c"` in `"abcd"`, the result is expected to be `["ab", "d"]`. Actually `["a", "d"]` is returned. `(?<=)` operator seems to work expectedly. -- https://bugs.ruby-lang.org/ Unsubscribe: