I have this List in Scala:
List[String] = List([[aaa|bbb]], [[ccc|ddd]], [[ooo|sss]])
And I want to obtain the same List with the substrings between | and ] removed and | removed too.
So the result would be:
List[String] = List([[aaa]], [[ccc]], [[ooo]])
I tried something making a String with the List and using replaceAll, but I want to conserve the List.
Thanks.
Here is a simple solution that should be quite good in performance:
val list = List("[[aaa|bbb]]", "[[ccc|ddd]]", "[[ooo|sss]]")
list.map(str => str.takeWhile(_ != '|') + "]]" )
It assumes that the format of the strings is:
[
at the beginning,|
. If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With