scala字符替换_如何替换Scala中的“坏”字符?
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方法,將其替換為對網絡友好的 。
替換Scala中壞字符的程序 (Program to replace bad characters in 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
輸出量
" " " "翻譯自: https://www.includehelp.com/scala/how-to-replace-bad-character-in-scala.aspx
scala字符替換
總結
以上是生活随笔為你收集整理的scala字符替换_如何替换Scala中的“坏”字符?的全部內容,希望文章能夠幫你解決所遇到的問題。
                            
                        - 上一篇: 颐和园早上去还是下午去
 - 下一篇: operator.ne_Python o