壹Try胜仟言
别忘了 import scala.util.matching._
scala> var s = "a_b_c_d_e"
s: String = a_b_c_d_e
scala> val regex = new Regex("^([^_]*)_([^_]*)_([^_]*)_(.*)$")
regex: scala.util.matching.Regex = ^([^_]*)_([^_]*)_([^_]*)_(.*)$
scala> val regex(time, user,cust,ss ) = s
time: String = a
user: String = b
cust: String = c
ss: String = d_e
时间: 2024-10-06 08:08:36