Back

replace (clj)

(source)

function

(replace s match replacement)
Replaces all instance of match with replacement in s. The replacement is literal (i.e. none of its characters are treated specially) for all cases above except pattern / string. In match is pattern instance, replacement can contain $1, $2, etc. will be substituted with string that matcher the corresponding parenthesized group in pattern. If you wish your replacement string to be used literary, use `(cuerdas.regexp/escape replacement)`. Example: (replace "Almost Pig Latin" #"\b(\w)(\w+)\b" "$2$1ay") ;; => "lmostAay igPay atinLay"

Examples

penpot/penpot
(ns app.main.ui.cursors
  (:require-macros [app.main.ui.cursors :refer [cursor-ref cursor-fn collect-cursors]])
  (:require
   [app.util.timers :as ts]
   [cuerdas.core :as str]
   [rumext.v2 :as mf]))

    [:section.debug-icons-preview
     (for [[key value] entries]
       (let [value (if (fn? value) (value @rotation) value)]
         [:div.cursor-item {:key key}
          [:div {:style {:width "100px"
                         :height "100px"
                         :background-image (-> value (str/replace #"(url\(.*\)).*" "$1"))
                         :background-size "contain"
                         :background-repeat "no-repeat"
                         :background-position "center"
                         :cursor value}}]