split()函数:
def split(arg0: String): Array[String]
def split(arg0: String, arg1: Int): Array[String]
scala> \"a-b-c-d-e\".split(\"-\
res0: Array[String] = Array(a, b, c-d-e)scala> \"a-b-c-d-e\".split(\"-\
res1: Array[String] = Array(a, b, c, d-e)scala> \"a-b-c-d-e\".split(\"-\
res2: Array[String] = Array(a, b, c, d, e)scala> \"a-b-c-d-e\".split(\"-\
res3: Array[String] = Array(a, b, c, d, e)scala> \"a-b-c-d-e\".split(\"-\")
res6: Array[String] = Array(a, b, c, d, e)scala> \"a-b-c-d--e---\".split(\"-\")
res7: Array[String] = Array(a, b, c, d, \"\
//arg1=0,split函数尽可能多的匹配arg0,不保留处于末尾位置的空字符串,空字符串例外。⽐如:scala> \"--a-b-c-d--e---\".split(\"-\")
res8: Array[String] = Array(\"\scala> \"\".split(\"-\
res1: Array[String] = Array(\"\")
//arg1<0,保留末尾的空字符串scala> \"--a-b-c-d--e---\".split(\"-\
res0: Array[String] = Array(\"\
因篇幅问题不能全部显示,请点此查看更多更全内容