
- Clojure - Home
- Clojure - Overview
- Clojure - Environment
- Clojure - Basic Syntax
- Clojure - REPL
- Clojure - Data Types
- Clojure - Variables
- Clojure - Operators
- Clojure - Loops
- Clojure - Decision Making
- Clojure - Functions
- Clojure - Numbers
- Clojure - Recursion
- Clojure - File I/O
- Clojure - Strings
- Clojure - Lists
- Clojure - Sets
- Clojure - Vectors
- Clojure - Maps
- Clojure - Namespaces
- Clojure - Exception Handling
- Clojure - Sequences
- Clojure - Regular Expressions
- Clojure - Predicates
- Clojure - Destructuring
- Clojure - Date & Time
- Clojure - Atoms
- Clojure - Metadata
- Clojure - StructMaps
- Clojure - Agents
- Clojure - Watchers
- Clojure - Macros
- Clojure - Reference Values
- Clojure - Databases
- Clojure - Java Interface
- Clojure - Concurrent Programming
- Clojure - Applications
- Clojure - Automated Testing
- Clojure - Libraries
Clojure - Strings replace
Replaces all instance of a match in a string with the replacement string.
Syntax
Following is the syntax.
(replace str match replacement)
Parameters − str is the input string. match is the pattern which will be used for the matching process. replacement will be the string which will be replaced for each pattern match.
Return Value − The string which has the replaced value as per the pattern match.
Example
Following is an example of replace in 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 above program produces the following output.
The tutorial is about clojure
clojure_strings.htm
Advertisements