【发布时间】:2019-12-30 20:00:59
【问题描述】:
我使用this 定义了一个函数,如果字符串匹配某个模式,则返回 0,否则返回 0:
def verif (s:String): Int = {
val p = """[0-9]{4}-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|3[0-1]) (2[0-3]|[01][0-9]):[0-5][0-9]:[0-5][0-9].[0-9]{9}""".r
s match {
case p(item) => 0
case _ => 1
}
}
当我执行时:
verif("2019-07-01 00:00:00.000000000") // Returns 1
【问题讨论】:
标签: scala pattern-matching case