FAQ Database Discussion Community

Scala Comprehension Errors

I am working on some of the exercism.io exercises. The current one I am working on is for Scala DNA exercise. Here is my code and the errors that I am receiving: For reference, DNA is instantiated with a strand String. This DNA can call count (which counts the strand...

Scala string pattern matching for html tagged contents extraction

Given a HTML page fetched from val html = io.Source.fromURL("http://example.org/aPage.html").mkString() how to extract the contents wrapped within a given tag ? To illustrate this consider for instance this HTML fragment and tag <textarea>, val html = "<p>Marginalia</p> <textarea rows="3" cols="10">Contents of interest"</textarea <p>More marginalia</p>" how to obtain "Contents of interest"...

Scala string replacement of entire words that comply with a pattern

In a string, how to replace words that start with a given pattern ? For instance replace each word that starts with "th", with "123", val in = "this is the example, that we think of" val out = "123 is 123 example, 123 we 123 of" Namely how to...