Clojure Strings replace
2018-12-21 14:11 更新
将字符串中的匹配的所有实例替换为替换字符串。
语法
以下是replace的基本使用语法:
(replace str match replacement)
参数− 'str'是输入字符串。 'match'是将用于匹配过程的模式。 'replacement'将是每个模式匹配将被替换的字符串。
返回值 − 匹配替换后的字符串。
例
下面是replace函数的示例:
(ns clojure.examples.hello
(:gen-class))
(defn hello-world []
(println (clojure.string/replace "The tutorial is about Groovy" #"Groovy"
"Clojure")))
(hello-world)输出
以上示例将输出以下结果:
The tutorial is about clojure
以上内容是否对您有帮助:

免费 AI IDE


更多建议: