lundi 20 avril 2015

Split string by "|~|" in scala

In python I can do this:

In [4]: "string1|~|string2".split("|~|")
Out[4]: ['string1', 'string2']

However, the same code in scala does not give me the expected output:

scala> "string1|~|string2".split("|~|")
res3: Array[java.lang.String] = Array("", s, t, r, i, n, g, 1, |, ~, |, s, t, r, i, n, g, 2)

I looked into this question How to split a string by a string in Scala and it seems that my code should work, but it does not. What am I missing? How do I get my desired output?

Aucun commentaire:

Enregistrer un commentaire