Exercise: Spell Checking

Fixing spelling mistakes

One aspect of fixing spelling mistakes is to find and replace incorrect words.

Is there a function in Clojure or one of its libraries we can use to replace the mis-spelt word in these sentences?

"simplicity ovr complexity"

Or maybe someone has broken letter h and you can help with that?

"ello friends. ello Clojurians. ello developers around our world."

()
Reveal answer...

Again, the clojure.string library helps us by providing the replace function.

;; Replace in this string the characters ovr with the characters over

(clojure.string/replace "simplicity ovr complexity" "ovr" "over")
;; => "simplicity over complexity"


(clojure.string/replace "ello friends. ello Clojurians. ello developers around our world." "ello" "Hello")
;; => "Hello friends. Hello Clojurians. Hello developers around our world."

The clojure.stringclojure.string library

Remember that there are specific functions you can use in the clojure.string library

results matching ""

    No results matching ""