Come dividere una stringa con un delimitatore da destra?Come dividere una stringa per delimitatore da destra?
ad es.
scala> "hello there how are you?".rightSplit(" ", 1)
res0: Array[java.lang.String] = Array(hello there how are, you?)
Python ha un metodo .rsplit()
che è quello che sto cercando in Scala:
In [1]: "hello there how are you?".rsplit(" ", 1)
Out[1]: ['hello there how are', 'you?']
'lastIndexOf' può tornare' -1'. – huynhjl
@huynhjl In questo caso 'splitAt' restituirà prima una stringa vuota e la stringa originale secondo. –
Dang, hai pensato a tutto! Hai ragione funziona. – huynhjl