vendredi 17 avril 2015

Scala easiest partial string matching

I have a quick question about Scala part string matching. Consider the example:



val s1 = "game of thrones"
val s2 = Array["throne videos", "watch game", "game of thrones stuff"]


and I want to do some kind of regex or matching or .contains such that in the result should be some thing like



val result = Array["videos", "watch", "stuff"]


where any word in the string that is repeated in s1 is cut out. What would be the most efficient way?


I am currently doing it by making s1 into a regex and applying it to each line of s2, but I am also having trouble with getting it to work.


Much thanks!


Aucun commentaire:

Enregistrer un commentaire