Skip to content

fix(string): apply Java's split rules in clojure.string/split - #46

Merged
skydread1 merged 1 commit into
maint-1.11.xfrom
fix/string-split-trailing-empties
Sep 8, 2026
Merged

fix(string): apply Java's split rules in clojure.string/split#46
skydread1 merged 1 commit into
maint-1.11.xfrom
fix/string-split-trailing-empties

Conversation

@skydread1

Copy link
Copy Markdown
Member

Closes #45

  • clojure.string/split now matches JVM Clojure. It drops trailing empty strings. A negative limit returns every part instead of throwing ArgumentOutOfRangeException. It also drops an empty first part when the pattern matches nothing at the start.
  • (split "" #",") returns [""], and (split "," #",") returns []. Java returns the input unsplit when nothing matches, before it drops anything.

@skydread1
skydread1 force-pushed the fix/string-split-trailing-empties branch from 47c856a to 133e38a Compare September 7, 2026 09:01
@skydread1 skydread1 self-assigned this Sep 7, 2026
.NET's Regex.Split has none of Java's three split rules, so they are
applied here. Java drops trailing empty strings at limit 0. It returns
every part at a negative limit. It also drops a leading empty part when
the pattern matches nothing at the start.
@skydread1
skydread1 force-pushed the fix/string-split-trailing-empties branch from 133e38a to 38a9f48 Compare September 7, 2026 09:22
@skydread1
skydread1 merged commit 5302b68 into maint-1.11.x Sep 8, 2026
3 checks passed
@skydread1
skydread1 deleted the fix/string-split-trailing-empties branch September 8, 2026 07:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

clojure.string/split returns trailing empty strings, and a negative limit throws

1 participant