ClojureScript

clojure.string/split adds separator matches & failed matches (nil) when the separator is a regex with alternation

Details

  • Type: Defect Defect
  • Status: Open Open
  • Priority: Minor Minor
  • Resolution: Unresolved
  • Affects Version/s: 0.0-3308
  • Fix Version/s: None
  • Component/s: None
  • Labels:
    None

Description

I want to split a string on "; ", and optionally discard a final ";". So, I tried:

(clojure.string/split "ab; ab;" #"(; )|(;$)")

In Clojure, this does what I want:

["ab" "ab"]

In ClojureScript, I get:

["ab" "; " nil "ab" nil ";"]

I'm not sure to what extent this is a platform distinction and to what extent it's a bug. Returning nils and seperators from clojure.string/split's output seems like it's against string.split's contract?

Activity

People

  • Assignee:
    Unassigned
    Reporter:
    lvh
Vote (0)
Watch (0)

Dates

  • Created:
    Updated: