讓我先說我是真正的新科特林但我有點熟悉Python前言本。刪除從字符串出現在科特林
我的目標是通過某種功能,從另一個字符串中刪除字符所有出現在一個字符串。
我可以告訴你我會怎麼做這在Python:
def removechars (s, chars)
return s.translate(None, chars)
而且我可以這樣使用它:
print(removechars("The quick brown fox jumped over the sleazy dog!", "qot"))
它將給這個輸出:
The uick brwn fx jumped ver the sleazy dg!
我怎麼能在Kotlin裏有類似的東西?
我不知道Kotlin,但它看起來並不像你[轉義](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.text/-regex/escape.html ) 那些角色。如果我設置了'chars =「[] \」'正則表達式將是'[[] \]'。 –