如何从右侧通过分隔符拆分字符串?
例如
scala> "hello there how are you?".rightSplit(" ", 1)
res0: Array[java.lang.String] = Array(hello there how are, you?)
Python 有一个.rsplit()
方法,这是我在 Scala 中所追求的:
In [1]: "hello there how are you?".rsplit(" ", 1)
Out[1]: ['hello there how are', 'you?']