博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
scala字符替换_如何替换Scala中的“坏”字符?
阅读量:2529 次
发布时间:2019-05-11

本文共 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方法,将其替换为对网络友好的

替换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

输出量

""""

翻译自:

scala字符替换

转载地址:http://cexzd.baihongyu.com/

你可能感兴趣的文章
VsVim - Shortcut Key (快捷键)
查看>>
C++练习 | 模板与泛式编程练习(1)
查看>>
HDU5447 Good Numbers
查看>>
08.CXF发布WebService(Java项目)
查看>>
java-集合框架
查看>>
RTMP
查看>>
求一个数的整数次方
查看>>
点云PCL中小细节
查看>>
铁路信号基础
查看>>
RobotFramework自动化2-自定义关键字
查看>>
[置顶] 【cocos2d-x入门实战】微信飞机大战之三:飞机要起飞了
查看>>
BABOK - 需求分析(Requirements Analysis)概述
查看>>
第43条:掌握GCD及操作队列的使用时机
查看>>
Windows autoKeras的下载与安装连接
查看>>
CMU Bomblab 答案
查看>>
微信支付之异步通知签名错误
查看>>
2016 - 1 -17 GCD学习总结
查看>>
linux安装php-redis扩展(转)
查看>>
Vue集成微信开发趟坑:公众号以及JSSDK相关
查看>>
技术分析淘宝的超卖宝贝
查看>>