【今日湯底】
Trolls are attacking your comment section!
A common way to deal with this situation is to remove all of the vowels from the trolls' comments, neutralizing the threat.
Your task is to write a function that takes a string and return a new string with all vowels removed.
For example, the string "This website is for losers LOL!" would become "Ths wbst s fr lsrs LL!".
Note: for this kata y isn't considered a vowel.
(必須通過以下測試)
(ns kata.test
(:require [clojure.test :refer :all]
[kata :refer [find_shortest]]))
(deftest basic-tests
(is (= (find_shortest "bitcoin take over the world maybe who knows perhaps") 3))
(is (= (find_shortest "turns out random test cases are easier than writing out basic ones") 3))
(is (= (find_shortest "lets talk about javascript the best language") 3))
(is (= (find_shortest "i want to travel the world writing code one day") 1))
(is (= (find_shortest "Lets all go on holiday somewhere very cold") 2))
)
【我的答案】
(ns disemvowel-trolls)
(defn disemvowel
[string]
(.replaceAll string "[aeiouAEIOU]" "")
)
思路:
【其他人的答案】
(ns disemvowel-trolls)
(defn disemvowel
[string]
(clojure.string/replace string #"(?i)[aeiou]" ""))
(ns disemvowel-trolls)
(defn disemvowel [string]
(->> string
(remove (set "aeiouAEIOU"))
(apply str)))