Scala - 正则表达式匹配例子
壹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
作者:Lighting Cui
出处:http://tugeler.cnblogs.com/
本文版权归作者所,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。
出处:http://tugeler.cnblogs.com/
本文版权归作者所,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。