用替换字符串替换字符串中所有匹配的实例。
replace - 语法
以下是语法。
(replace str match replacement)
参数 - str是输入字符串, "match"是用于匹配过程的模式, "replacement"将是将在每次模式匹配中替换的字符串。
返回值 - 根据模式匹配具有替换值的字符串。
replace - 示例
以下是Clojure中的替换示例。
(ns clojure.examples.hello (:gen-class)) (defn hello-Learnfk [] (println (clojure.string/replace "The tutorial is about Groovy" #"Groovy" "Clojure"))) (hello-Learnfk)
上面的程序产生以下输出。
The tutorial is about clojure