mirror of
https://github.com/ruby/ruby.git
synced 2025-08-28 07:26:00 +02:00
string.c(rb_str_split_m): Handle /\K/ correctly
Use BEG(0) instead of the result of rb_reg_search to handle the cases when the separator Regexp contains /\K/ (lookbehind) operator. Fixes [Bug #17113]
This commit is contained in:
parent
66efe37311
commit
e79cdcf61b
Notes:
git
2020-08-12 10:02:06 +09:00
2 changed files with 7 additions and 1 deletions
|
@ -1838,6 +1838,11 @@ CODE
|
|||
assert_equal("abc", s)
|
||||
end
|
||||
|
||||
def test_split_lookbehind
|
||||
assert_equal([S("ab"), S("d")], S("abcd").split(/(?<=b)c/))
|
||||
assert_equal([S("ab"), S("d")], S("abcd").split(/b\Kc/))
|
||||
end
|
||||
|
||||
def test_squeeze
|
||||
assert_equal(S("abc"), S("aaabbbbccc").squeeze)
|
||||
assert_equal(S("aa bb cc"), S("aa bb cc").squeeze(S(" ")))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue