如何在Scala中从文本中删除数字?

例如我有这段文字:

canon 40 22mm lens lock strength plenty orientation 321 .

删除后:
canon lens lock strength plenty orientation .

最佳答案

请尝试filterfilterNot

val text = "canon 40 22mm lens lock strength plenty orientation 321 ."
val without_digits = text.filter(!_.isDigit)

或者
val text = "canon 40 22mm lens lock strength plenty orientation 321 ."
val without_digits = text.filterNot(_.isDigit)

关于regex - 如何从Scala中的文本中删除数字?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/30474082/

10-11 21:19