Skip to content

Commit

Permalink
Showing 2 changed files with 4 additions and 1 deletion.
1 change: 1 addition & 0 deletions spec/std/string_spec.cr
Original file line number Diff line number Diff line change
@@ -716,6 +716,7 @@ describe "String" do
assert { "a=".split(/\=/).should eq(["a", ""]) }
assert { "=b".split(/\=/).should eq(["", "b"]) }
assert { "=".split(/\=/, 2).should eq(["", ""]) }
assert { ",".split(/(?:(x)|(,))/).should eq(["", ",", ""]) }

it "keeps groups" do
s = "split on the word on okay?"
4 changes: 3 additions & 1 deletion src/string.cr
Original file line number Diff line number Diff line change
@@ -2466,7 +2466,9 @@ class String
count += 1

1.upto(match.size) do |i|
ary.push match[i]
if group = match[i]?
ary.push group
end
end

last_slice_offset = slice_offset

0 comments on commit 2754433

Please sign in to comment.