Scala 日常操作备忘

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
:15: error: value mkstring is not a member of String
       TAKE_ZH findAllIn(str).mkstring
                              ^

scala> (TAKE_ZH findAllIn(str)).mkstring
: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 日常操作备忘)