目录

replace

用替换字符串替换字符串中匹配的所有实例。

语法 (Syntax)

以下是语法。

(replace str match replacement)

Parameters - 'str'是输入字符串。 'match'是将用于匹配过程的模式。 'replacement'将是每个模式匹配将被替换的字符串。

Return Value - 根据模式匹配具有替换值的字符串。

例子 (Example)

以下是Clojure中的替换示例。

(ns clojure.examples.hello
   (:gen-class))
(defn hello-world []
   (println (clojure.string/replace "The tutorial is about Groovy" #"Groovy"
      "Clojure")))
(hello-world)

输出 (Output)

上述程序产生以下输出。

The tutorial is about clojure
↑回到顶部↑
WIKI教程 @2018