Create a script in Scala to remove all whitespace from a string

回复样本
Here's a Scala script to remove all whitespace from a string using the `replaceAll` method: ``` val str = " Hello, world! " val result = str.replaceAll("\\s", "") println(result) ``` The output will be: ``` Hello,world! ``` Explanation: The `\\s` pattern matches any whitespace character (e.g., space, tab, newline), and the `replaceAll` method replaces all occurrences of this pattern with an empty string.
出版日期: 1 年前