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