From: kasumi@... Date: 2020-08-13T17:10:50+00:00 Subject: [ruby-core:99581] [Ruby master Bug#17120] String#start_with? return wrong result for Regexp patterns containing /\K/ Issue #17120 has been updated by hanazuki (Kasumi Hanazuki). Patch: https://github.com/ruby/ruby/pull/3417 ---------------------------------------- Bug #17120: String#start_with? return wrong result for Regexp patterns containing /\K/ https://bugs.ruby-lang.org/issues/17120#change-87053 * Author: hanazuki (Kasumi Hanazuki) * Status: Open * Priority: Normal * ruby -v: ruby 2.8.0dev (2020-08-13T01:14:20Z master 69b5241c36) [x86_64-linux] * Backport: 2.5: UNKNOWN, 2.6: UNKNOWN, 2.7: UNKNOWN ---------------------------------------- `String#start_with?` unexpectedly reports true when the pattern Regexp contains `/\K/` (lookbehind) operator and the lookbehind pattern matches the beginning of `self`. ```ruby "hello".start_with?(/h\Ke/) # => true (unexpected) ``` In this example, `/h\Ke/` matches "hello", but it's not considered as a match at the beginning of the string by the other Regexp operations (e.g. `$~.begin(0) == 1`). -- https://bugs.ruby-lang.org/ Unsubscribe: