What is the idiomatic scala way of finding, if a given string contains a given substring?
If you want to do it with maximum efficiency, you may have to write it yourself (or find a good substring searching algorithm somewhere). If you just want it to work at all, then in Scala:
scala> "Finding needle in haystack" contains "needle"
res0: Boolean = true
scala> "Finding needle in haystack" indexOf "needle"
res1: Int = 8
These are not regex searches. You aren't using the regex match correctly either (edit: because that code asks for an exact match to the whole string, not to find a matching substring), but that's a different issue. If you want a count of the number of matches, you can do something like
scala> "needle".r.findAllIn("Finding needle in haystack").length
res2: Int = 1
Although answered I thought I would also offer this regex style
scala> "I have a needle in my haystack" matches ".*needle.*"
res10: Boolean = true