chocolateboy/string_splitter

remove_empty removes non-empty delimiters

Closed this issue · 1 comments

StringSplitter 1.1.1
Rubyruby 2.5.3p105 (2018-10-18 revision 65156) [x86_64-linux]
OSLinux (Arch)

The remove_empty option removes empty fields, as expected, but it also appears to be removing non-empty delimiters.

Test

ss = StringSplitter.new(remove_empty: true, include_captures: true)
ss.split("::", ":")

Expected

[":", ":"]

Actual

[]

Forgot to capture the delimiter:

ss = StringSplitter.new(remove_empty: true, include_captures: true)
ss.split("::", /(:)/)
# => [":", ":"] ✔