The Scala String method (in class StringOps) stripMargin removes leading whitespace from each line of a multi-line String up to and including the pipe (|) character (or other designated delimiter).
Is there an equivalent method to remove trailing whitespace from each line?
I did a quick look through the Scaladocs, but could not find one.
You can easily use a regex for that:
The
(?m)prefix in the regex makes it a multiline regex.\s+matches 1 or more whitespace characters and$the end of the line (because of the multiline flag).