I have two strings in scala and I want to find out, if the bigger string (needle
) contains a smaller string (haystack
).
What I found is doing it with regexps and matches like this (from this question):
needle.r.pattern.matcher(haystack).matches
which is (1) grossly overcomplicated for such a simple problem, but more importantly, (2) doesn't work for me, because
"needle".r.pattern.matcher("Finding needle in haystack").matches
returns
Boolean = false