本文共 1290 字,大约阅读时间需要 4 分钟。
scala字符替换
In Scala, programming language, all sorts of special characters are valid. The character set library is quite good and supports almost all characters in Scala programming.
在编程语言Scala中,各种特殊字符均有效。 字符集库非常好,并支持Scala编程中的几乎所有字符。
But some displays do not support the use of all character and while programming this may create an issue as the display will misbehave and the output may get some errors. A display like Radio Pi and some web displays do not support characters like “, ” , ‘ , ’.
但是某些显示器不支持使用所有字符,并且在编程时这可能会引起问题,因为显示器将无法正常工作,并且输出可能会出现一些错误。 诸如Radio Pi之类的显示器和某些Web显示器不支持诸如“,”,“,”之类的字符。
These characters are needed to be handled to get perfect output. For this in Scala, we can create a Scala method that replaces these bad characters with web-friendly once's.
需要处理这些字符以获得完美的输出。 为此,我们可以在Scala中创建一个Scala方法,将其替换为对网络友好的 。
object MyClass { def replacebad(s: String): String = { s.replaceAll("“", "\"") .replaceAll("”", "\"") .replaceAll("‘", "\"") .replaceAll("’", "\"") } def main(args: Array[String]) { println(replacebad("“")) println(replacebad("”")) println(replacebad("‘")) println(replacebad("’")) }}
Output
输出量
""""
翻译自:
scala字符替换
转载地址:http://cexzd.baihongyu.com/