This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-07-25
Channels
- # babashka (9)
- # beginners (56)
- # calva (18)
- # clj-kondo (2)
- # clojars (2)
- # clojure (46)
- # clojure-boston (1)
- # clojure-europe (4)
- # clojurescript (10)
- # css (1)
- # data-science (2)
- # emacs (10)
- # girouette (1)
- # helix (10)
- # jobs-discuss (4)
- # malli (2)
- # off-topic (28)
- # polylith (5)
- # re-frame (4)
- # reitit (8)
- # releases (6)
- # rewrite-clj (1)
- # sci (44)
- # sql (10)
- # tools-deps (31)
Hey, how do I check if a string contains a particular character or sequence of characters in ClojureScript?
Would I have to use clojure.string/includes?
Clojure has regex literals: https://purelyfunctional.tv/mini-guide/regexes-in-clojure/
Thanks. I went with clojure.string/includes?
Hey, say I would like to render an element conditionally using an if, how would I express that in ClojureScript? It seems straight forward but my attempt always seems to execute what should be the else. I tried something like this:
(if (clojure.string/includes? "this" "this and that")
[:div {} "Something"]
[:img {:src "/images/image.png"}])
you might have the arguments swapped
> (clojure.string/includes? "this" "this and that")
false
> (clojure.string/includes? "this and that" "this" )
true
Ah, I see.
Thanks.