用替换字符串替换字符串中所有匹配的实例。
以下是语法。
链接:https://www.learnfk.comhttps://www.learnfk.com/clojure/clojure-strings-replace.html
来源:LearnFk无涯教程网
(replace str match replacement)
参数 - 'str'是输入字符串, "match"是用于匹配过程的模式, "replacement"将是将在每次模式匹配中替换的字符串。
返回值 - 根据模式匹配具有替换值的字符串。
以下是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
祝学习愉快!(内容编辑有误?请选中要编辑内容 -> 右键 -> 修改 -> 提交!)