Scala: How to convert multiple spaces to a single space (regex)
Briefly

The key is to first call trim to remove any leading and trailing spaces, and then call replaceAll to convert one or more blank spaces to a single space.
The code I show is a simple adaptation of the Java code I found on SO.
Read at Alvinalexander
[
]
[
|
]