美文网首页
Scala 日常操作备忘

Scala 日常操作备忘

作者: 一条湫刀鱼 | 来源:发表于2017-09-30 11:25 被阅读8次
    scala> val str = "崔*华"
    str: String = 崔*华
    
    scala> val strs = str.split("")
    strs: Array[String] = Array(崔, *, 华)
    
    scala> val TAKE_ZH = """[\x{4e00}-\x{9fa5}]""".r 
    TAKE_ZH: scala.util.matching.Regex = [\x{4e00}-\x{9fa5}]
    
    scala> import scala.util.matching.Regex
    import scala.util.matching.Regex
    
    scala> TAKE_ZH findAllIn(str)
    res0: scala.util.matching.Regex.MatchIterator = non-empty iterator
    
    scala> TAKE_ZH findAllIn(str).mkstring
    <console>:15: error: value mkstring is not a member of String
           TAKE_ZH findAllIn(str).mkstring
                                  ^
    
    scala> (TAKE_ZH findAllIn(str)).mkstring
    <console>:15: error: value mkstring is not a member of scala.util.matching.Regex.MatchIterator
           (TAKE_ZH findAllIn(str)).mkstring
                                    ^
    
    scala> (TAKE_ZH findAllIn(str)).mkString
    res3: String = 崔华
    

    相关文章

      网友评论

          本文标题:Scala 日常操作备忘

          本文链接:https://www.haomeiwen.com/subject/lveuextx.html