Clojure-strings-replace
提供:Dev Guides
Clojure-文字列の置換
文字列内の一致のすべてのインスタンスを置換文字列で置き換えます。
構文
構文は次のとおりです。
(replace str match replacement)
パラメータ-「str」は入力文字列です。 「一致」は、一致プロセスに使用されるパターンです。 「置換」は、パターンマッチごとに置換される文字列です。
戻り値-パターンマッチごとに置き換えられた値を持つ文字列。
例
Clojureでの置き換えの例を次に示します。
(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