How do I compare these two string :
val a = "fit bit versa"
val b = "fitbit"
another example
val a = "go pro hero 6"
val b = "gopro"
another example
val a = "hero go pro 6"
val b = "gopro"
another example
val a = "hero 6 go pro"
val b = "gopro"
I want to get "true" for the above comparisons but not here:
val a = "vegan protein powder"
val b = "vega"
This should be false.
Currently I am doing:
def matchPattern(a:String, b: String):String=
{
val dd = a.split(" ")
val result = dd.map(_.toLowerCase())
if(result contains b.toLowerCase) true
else false
}
This works for last case but not the rest.
Any suggestion ?