I had the afterthought that my examples were a bit odd. As far as splitting with regex is concerned Clojure and Clojurescript behaviour is significantly different in my experience. In my use case I gave up trying to find regex patterns that would work for both clj and cljs and started writing platform specific patterns. Luckily Clojure 1.7.0 is being rolled out at the moment and it includes Reader Conditionals allowing to write these bilingual libraries easily.
On Mon, Apr 20, 2015 at 9:12 PM, Francis Avila <[email protected]> wrote: > This is an edge case of clojure.string/split with limits and non-consuming > assertions. ^ and $ are fully supported with the meaning of the underlying > regex engine (which may be subtly different in javascript and java). > > This is clearly wrong. It occurs because clojure.string/match uses the > size of the match to determine where to split. Since the match is always > empty, it always splits at index 0. > > cljs.user=> (clojure.string/split "123" #"$" 2) > ["" "123"] > > > However, I'm not sure why you consider Clojure's answers to be correct. I > would expect this in Clojure: > > user=>(clojure.string/split "123" #"^" 2) > ["" "123"] > > > > On Sunday, April 19, 2015 at 10:39:28 AM UTC-5, Dominykas Mostauskis wrote: > > I am having trouble using the ^ and $ characters under Clojurescript. > Equivalent calls in Clojure work fine. Workarounds? > > > > Unexpected cljs behaviour: > > > > cljs.user=> (clojure.string/split "123" #"$" 2) > > ["" "123"] > > cljs.user=> (clojure.string/split "123" #"^" 2) > > ["" "123"] > > > > Clojure works fine: > > > > user=> (clojure.string/split "123" #"$" 2) > > ["123" ""] > > user=> (clojure.string/split "123" #"^" 2) > > ["123"] > > -- > Note that posts from new members are moderated - please be patient with > your first post. > --- > You received this message because you are subscribed to a topic in the > Google Groups "ClojureScript" group. > To unsubscribe from this topic, visit > https://groups.google.com/d/topic/clojurescript/v8TqycN6ZMQ/unsubscribe. > To unsubscribe from this group and all its topics, send an email to > [email protected]. > To post to this group, send email to [email protected]. > Visit this group at http://groups.google.com/group/clojurescript. > -- Note that posts from new members are moderated - please be patient with your first post. --- You received this message because you are subscribed to the Google Groups "ClojureScript" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/clojurescript.
